ssl: Fix building with older OpenSSL too

This commit is contained in:
Patrick Griffis 2016-10-23 01:08:13 -04:00
parent 217fa9d0f9
commit 1186236ac1
1 changed files with 8 additions and 2 deletions

View File

@ -294,14 +294,20 @@ SSL *
_SSL_socket (SSL_CTX *ctx, int sd) _SSL_socket (SSL_CTX *ctx, int sd)
{ {
SSL *ssl; SSL *ssl;
const SSL_METHOD *method;
if (!(ssl = SSL_new (ctx))) if (!(ssl = SSL_new (ctx)))
/* FATAL */ /* FATAL */
__SSL_critical_error ("SSL_new"); __SSL_critical_error ("SSL_new");
SSL_set_fd (ssl, sd); SSL_set_fd (ssl, sd);
if (SSL_CTX_get_ssl_method (ctx) == SSLv23_client_method())
#if OPENSSL_VERSION_NUMBER < 0x10100000L
method = ctx->method;
#else
method = SSL_CTX_get_ssl_method (ctx);
#endif
if (method == SSLv23_client_method())
SSL_set_connect_state (ssl); SSL_set_connect_state (ssl);
else else
SSL_set_accept_state(ssl); SSL_set_accept_state(ssl);