I think you missed the logic about the function return value. If SSL_set_fd( ) is ok , it will return "1".
Your code may write this way: if( !SSL_set_fd(si->ssl, sock)){ int err_tmp = ERR_get_error(); char buf_tmp[256]; ERR_error_string_n(err_tmp, buf_tmp, sizeof(buf_tmp)); log(ERROR, buf_tmp); fsl_err = FSL_ERROR_CANNOTSETSSLFD; } At 2011-02-25 22:21:21,ikuzar <razuk...@gmail.com> wrote: SSL_set_fd( ) also fails. to know what exactly happened, I tried somthing like this : if(SSL_set_fd(si->ssl, sock)){ int err_tmp = ERR_get_error(); char buf_tmp[256]; ERR_error_string_n(err_tmp, buf_tmp, sizeof(buf_tmp)); log(ERROR, buf_tmp); fsl_err = FSL_ERROR_CANNOTSETSSLFD; } BUT I have got this message : error:00000000:lib(0):func(0):reason(0) how to know what happens ...? What does this error mean ? Thanks. 2011/2/25 Aro RANAIVONDRAMBOLA<razuk...@gmail.com> Hello, I realize that when my program calls SSL_CTX_use_certificate_file, it returns an error because the certificate does not match the private key. I would to process this kind of error. SSL_get_error( ) does not treat this case. I would like to know what is THE function wich enable me to extract the errors type ( in my case I want to retrieve error like SSL_ERROR_PVKEY_DOES_NOT_MATCH_WITH_CERT ) Thanks for your help.