我具有以下代码来实现Openssl,并且一切似乎都正常(没有错误报告),但是以某种方式对流量进行tcpdump时,我看不到握手。我看到收到了字节,但似乎未使用SSL协议。
open socket
bind to socket
listen on socket
SSL_load_error_strings();
SSL_library_init();
OpenSSL_add_all_algorithms();
method = SSLv23_server_method();
ctx = SSL_CTX_new(method);
if (!ctx) {
err = -1;
}
SSL_CTX_set_ecdh_auto(ctx, 1);
/* Set the key and cert */
if (SSL_CTX_use_certificate_file(ctx, ccrt, SSL_FILETYPE_PEM) <= 0) {
err = -1;
}
if (SSL_CTX_use_PrivateKey_file(ctx, ckey, SSL_FILETYPE_PEM) <= 0 ) {
err = -1;
}
// end of SSL setup
for(;;)
{
if (new connection)
accept new client connection
else (existing connection and something to read/write)
{
rc = SSL_read(ssl, buffer, length);
check rc for bytes read and/or error
}
}