<div dir="ltr"><div><div><div><div><div>I have the following code:<br><br>setup_ssl (char *server_name, char *port, SSL_CTX *ctx)<br>{<br>    BIO *output = BIO_new_ssl_connect (ctx);<br>    if (!output)<br>    {<br>        return (NULL);<br>    }<br>    BIO_get_ssl (output, &ssl);<br>    SSL_set_mode (ssl, SSL_MODE_AUTO_RETRY);<br>    SSL_set_verify (ssl, true, NULL);<br>    BIO_set_conn_hostname (output, server_name);<br>    BIO_set_conn_port(output, port);<br><br>    if (BIO_do_connect (output) <= 0)<br>    {<br>        BIO_free (output);<br>        return (NULL);<br>    }<br>}<br><br></div>If the server I'm trying to connect to does not have ssl enabled, I get the error:<br>SSL23_GET_SERVER_HELLO:unknown protocol<br></div>and BIO_do_connect fails as expected, but BIO_free gives this error:<br>SSL_shutdown:shutdown while in init<br><br></div>If I don't free it, I have a memory leak.<br></div>Is there something else I need to do to clean up the BIO?<br></div>I tried calling BIO_do_handshake, but that crashes (not surprised).<br><div><div><div><div><div><div><br>-- <br><div class="gmail-m_-3123107597729068210gmail_signature">Chris Bare</div>
</div></div></div></div></div></div></div>