I looked at the stack overflow and the internet, but I could not find the answer to the question why ssl_accept () keeps coming back:
[DEBUG] SSL_accept() : Failed with return 0
[DEBUG] SSL_get_error() returned : 5
[DEBUG] Error string : error:00000005:lib(0):func(0):DH lib
[DEBUG] WSAGetLastError() returned : 0
[DEBUG] GetLastError() returned : 0
[DEBUG] ERR_get_error() returned : 0
Edit: Of interest, ssl_accept () returns 0, defined as (according to the meager and useless OpenSSL documentation): "The TLS / SSL handshake was unsuccessful, but was disabled with the control and specifications of the TLS / SSL protocol. Call SSL_get_error () with the return ret value to find out the reason. "
Below is a snippet on the server side, can I bark the wrong tree, and this problem is caused by the client code?
client = accept( server, (sockaddr*) &clientsockaddrin, &len );
SSL* ssl = SSL_new( ctx );
SSL_set_fd( ssl, client );
std::cout << "+--------------------------------------------------+"
<< std::endl;
int r = SSL_accept( ssl );
if ( r != 1 )
{
int err_SSL_get_error = SSL_get_error( ssl, r);
int err_GetLastError = GetLastError();
int err_WSAGetLastError = WSAGetLastError();
int err_ERR_get_error = ERR_get_error();
std::cout << "[DEBUG] SSL_accept() : Failed with return "
<< r << std::endl;
std::cout << "[DEBUG] SSL_get_error() returned : "
<< err_SSL_get_error << std::endl;
std::cout << "[DEBUG] Error string : "
<< ERR_error_string( err_SSL_get_error, NULL )
<< std::endl;
std::cout << "[DEBUG] WSAGetLastError() returned : "
<< err_WSAGetLastError << std::endl;
std::cout << "[DEBUG] GetLastError() returned : "
<< err_GetLastError << std::endl;
std::cout << "[DEBUG] ERR_get_error() returned : "
<< err_ERR_get_error << std::endl;
std::cout << "+--------------------------------------------------+"
<< std::endl;
break;
}
Appreciate your help as it drives me crazy :(
source
share