Skip to content

Commit b026993

Browse files
rdlowreym6w6
authored andcommitted
Fixed segfault when built with OpenSSL >= 1.0.1
(PR #481)
1 parent b5a0f12 commit b026993

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

ext/openssl/openssl.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4613,9 +4613,6 @@ SSL *php_SSL_new_from_context(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{
46134613

46144614
GET_VER_OPT_STRING("local_cert", certfile);
46154615
if (certfile) {
4616-
X509 *cert = NULL;
4617-
EVP_PKEY *key = NULL;
4618-
SSL *tmpssl;
46194616
char resolved_path_buff[MAXPATHLEN];
46204617
const char * private_key = NULL;
46214618

@@ -4642,7 +4639,11 @@ SSL *php_SSL_new_from_context(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{
46424639
}
46434640
}
46444641

4645-
tmpssl = SSL_new(ctx);
4642+
#if OPENSSL_VERSION_NUMBER < 0x10001001L
4643+
/* Unnecessary as of OpenSSLv1.0.1 (will segfault if used with >= 10001001 ) */
4644+
X509 *cert = NULL;
4645+
EVP_PKEY *key = NULL;
4646+
SSL *tmpssl = SSL_new(ctx);
46464647
cert = SSL_get_certificate(tmpssl);
46474648

46484649
if (cert) {
@@ -4651,7 +4652,7 @@ SSL *php_SSL_new_from_context(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{
46514652
EVP_PKEY_free(key);
46524653
}
46534654
SSL_free(tmpssl);
4654-
4655+
#endif
46554656
if (!SSL_CTX_check_private_key(ctx)) {
46564657
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Private key does not match certificate!");
46574658
}

0 commit comments

Comments
 (0)