<div dir="ltr"><div><div><div><div><div><div><div><div><div><div><div><div>Hi,<br></div>I
 have a setup where the handshake between openssl server and client 
fails at times but not always. And when it does,  the client keeps 
retrying and all of trials fail. Only way to recover is to restart the 
server.<br></div><br>Currently on the server side the openssl version that I have installed is 1.0.1m.<br><br></div>Both
 server and client are written in C and are in non-blocking mode. I have
 added InfoCallBack and printCallBack routines on the server side.<br><br></div><div>On the server side application, I have set the following options;<br><br>    pCtx = SSL_CTX_new(SSLv23_server_<wbr>method());<br><br>    SSL_CTX_set_options(pCtx, SSL_OP_NO_SSLv2);<br>    SSL_CTX_set_options(pCtx, SSL_OP_NO_SSLv3);<br>    SSL_CTX_set_options(pCtx, SSL_OP_NO_TLSv1);<br><br></div><div><br></div>Now when the failure occurs, I get the following error message on the server side:<br><br>InfoCB<br>HANDSHAKE_START(time:5093879)  undefined: before/accept initialization<br><br>InfoCB<br>SSL_accept:before/accept initialization<br><br>InfoCB<br>SSL3 alert write:fatal:internal error<br><br>PrintCB<br>error:1408A044:SSL routines:SSL3_GET_CLIENT_<wbr>HELLO:internal error:/server/openssl/ssl/s3_<wbr>srvr.c:1265:<br><br>InfoCB<br>SSL_accept:error in SSLv3 read client hello C<br><br>InfoCB<br>SSL_accept:error in SSLv3 read client hello C<br><br><br></div></div>The
 SSL code path </server/openssl/ssl/s3_srvr.<wbr>c:1265> refers to the 
following section of code in ssl3_get_client_hello() routine in 
s3_srvr.c.<br><br>------------------------------<wbr>------------------------------<wbr>--------------<br>    /*<br>     * Check if we want to use external pre-shared secret for this handshake<br>     * for not reused session only. We need to generate server_random before<br>     * calling tls_session_secret_cb in order to allow SessionTicket<br>     * processing to use it in key derivation.<br>     */<br>    {<br>        unsigned char *pos;<br>        pos = s->s3->server_random;<br>        if (ssl_fill_hello_random(s, 1, pos, SSL3_RANDOM_SIZE) <= 0) {<br>#ifdef USER_EXTENSIONS<br>            SSLerr(SSL_F_SSL3_GET_CLIENT_<wbr>HELLO, ERR_R_INTERNAL_ERROR);<br>#endif // USER_EXTENSIONS<br>            goto f_err;<br>        }<br>    }<br>------------------------------<wbr>------------------------------<wbr>--------------<br></div><br>Note,
 I have edited the SSL library to include this USER_EXTENSIONS section, 
so that I could confirm where exactly this issue is happening in the 
library.<br><br></div>Clearly ssl_fill_hello_ramdom() routine is returning -1 or something less than zero.<br><br></div>I do not hit this issue always. <br><br>Any pointers on addressing this issue will be a big help.<br><br></div><br></div>Thanks,<br></div>Senthil.</div>