从缓冲区读取TLS数据到OpenSSL

时间:2014-07-18 14:33:01

标签: c sockets openssl

你好:)我试图设计一个EAP-TLS客户端。我根据this question设计了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

`

0 个答案:

没有答案