Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C 将TLS数据从缓冲区读取到OpenSSL中_C_Sockets_Openssl - Fatal编程技术网

C 将TLS数据从缓冲区读取到OpenSSL中

C 将TLS数据从缓冲区读取到OpenSSL中,c,sockets,openssl,C,Sockets,Openssl,你好:我正在尝试设计一个EAP-TLS客户端。我根据设计了TLS_client_hello,但现在我不知道如何将服务器的回复读取到相同的SSL上下文中,以便进一步处理证书验证/密钥交换。我使用原始套接字来设计数据包,并从打开的套接字读取到char[]数组中。这就是我到目前为止所做的: ctx = SSL_CTX_new(TLSv1_client_method()); SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL); ssl =

你好:我正在尝试设计一个EAP-TLS客户端。我根据设计了TLS_client_hello,但现在我不知道如何将服务器的回复读取到相同的SSL上下文中,以便进一步处理证书验证/密钥交换。我使用原始套接字来设计数据包,并从打开的套接字读取到char[]数组中。这就是我到目前为止所做的:

    ctx = SSL_CTX_new(TLSv1_client_method());
    SSL_CTX_set_verify(ctx, SSL_VERIFY_NONE, NULL);
    ssl = SSL_new(ctx);
    rbio = BIO_new(BIO_s_mem());
    wbio = BIO_new(BIO_s_mem());
    SSL_set_bio(ssl, rbio, wbio);
    SSL_set_connect_state(ssl);
    SSL_do_handshake(ssl);
    readbytes = BIO_read(wbio, buf, BUF_SIZ); //client_hello generated

   // different function,
   readbytes = BIO_write(rbio, temp, numbytes); // using the same BIO as above, temp contains the server_hello data

`

请发布您迄今为止尝试过的代码,并说明哪些代码不起作用。完成!我不知道如何让OpenSSL读取从服务器接收的数据。我试着将它复制到BIO中并使用SSL\u读取,但没有成功。你需要调用SSL\u do\u握手。基本上,您需要重复操作,直到SSL_do_handshake返回1,表示握手已完成。看一看,在我将新数据写入BIO后,我需要调用SSL\u do\u握手?是的,然后你必须再次调用读/写函数,以便握手继续进行,直到SSL\u do\u握手返回1,以指示握手完成。