工具与软件:
您好、 TI 工程师
、SDK 版本是6.10.00.05 μ s 使用 安全套接字 API 连接 服务器。 TCP 已连接 但 SSL 握手。
这是我的 安全套接字代码
ssl_fd = sl_Socket(AF_INET,SOCK_STREAM,0); if(ssl_fd<0) { goto tcp_error; } SlSockSecureMethod_t method; _i16 status; method.SecureMethod = SL_SO_SEC_METHOD_SSLv3_TLSV1_2; status = sl_SetSockOpt(ssl_fd,SL_SOL_SOCKET,SL_SO_SECMETHOD,&method,sizeof(SlSockSecureMethod_t)); SYS_LOGW(SSL_TAG,"sl_SetSockOpt SSL status=%d",status); SlSockSecureMask_t mask; mask.SecureMask = 0xFFFFF; status = sl_SetSockOpt(ssl_fd,SL_SOL_SOCKET,SL_SO_SECURE_MASK,&mask,sizeof(SlSockSecureMask_t)); SYS_LOGW(SSL_TAG,"sl_SetSockOpt SSL mask=%d",status); status = sl_SetSockOpt(ssl_fd,SL_SOL_SOCKET,SL_SO_SECURE_FILES_CA_FILE_NAME,"ssl_ca",strlen("ssl_ca")); _u32 dummyVal; status = sl_SetSockOpt(ssl_fd,SL_SOL_SOCKET, SL_SO_SECURE_DISABLE_CERTIFICATE_STORE,&dummyVal,sizeof(dummyVal)); ret = sl_Connect(ssl_fd,(struct sockaddr *)&dest, sizeof(dest)); if(ret!=0) { SYS_LOGE(SSL_TAG,"connect false,ret is %d,errno is %d\n",ret,errno); sl_Close(ssl_fd); sleep(1); goto create_socket; } SYS_LOGI(SSL_TAG,"tcp client connect success\n"); while(1) { ret = sl_Recv( ssl_fd, ssl_recv_buf, MAX_SSL_MSG ,0); if( ret < 0 ) { SYS_LOGE(SSL_TAG,"failed\n ! mbedtls_ssl_read returned %d,errno=%d\r\n", ret ,errno); break; } if( ret == 0 ) { SYS_LOGE(SSL_TAG,"server discon" ); break; } if(ssl_param.ssl_recv_deal) ssl_param.ssl_recv_deal(ssl_recv_buf,ret); } sl_Close(ssl_fd);