Hi!
II want to restart the same SSL session after calling SSL_shutdown(). I tried the following but it got stuck at SSL_connect(). I wonder if I can do either of the following on the client:
1) Call SSL_shutdown() but then reuse the same SSL object for a later SSL_connect().
or
2) Call SSL_shutdown() then SSL_free() then SSL_new() but reuse the old socket that I didn't close.
I tried the following but it doesn't work:
sock = new_socket_connect(); /* create and connect socket */
bio = BIO_new_socket(sock, BIO_NOCLOSE);
ssl = SSL_new(my_ssl_ctx);
SSL_set_bio(ssl, bio, bio);
SSL_connect(ssl);
/* SSL_write() */
/* shut down */
SSL_shutdown(ssl);
if(SSL_shutdown(ssl) != 1) {error_print("bad shutdown\n");}
/* Try to restart */
/* code for case 1) */
{
SSL_clear(ssl);
SSL_connect(ssl); /* This call hangs ?????? */
/* SSL_do_handshake(ssl) succeeds, but the following SSL_write(ssl) fails with error "SSL object shutdown" ??? */
}
/* code for case 2) */
{
sess = SSL_get1_session(ssl);
SSL_free(ssl);
ssl = SSL_new(my_ssl_ctx);
bio = BIO_new_socket(sock, BIO_NOCLOSE);
SSL_set_bio(ssl, bio, bio);
SSL_set_session(sess);
SSL_connect(ssl); /* This now hangs ???? */
}
Any suggestions?
Thank you in advance,
Ning