diff options
author | Lior Kaplan <kaplanlior@gmail.com> | 2013-10-18 22:57:51 +0300 |
---|---|---|
committer | Lior Kaplan <kaplanlior@gmail.com> | 2013-10-19 15:52:26 +0300 |
commit | 3f2474550cbf299d8a7df34988ece052a0401414 (patch) | |
tree | c31805aa899ff4bd51981781b1d1d79a6540e245 /ext/openssl | |
parent | 1fd24dd3e14010b82febd3e300599f8d8f9c592c (diff) | |
download | php-3f2474550cbf299d8a7df34988ece052a0401414.tar.gz |
Imported Upstream version 5.5.5+dfsg
Diffstat (limited to 'ext/openssl')
-rw-r--r-- | ext/openssl/openssl.c | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/ext/openssl/openssl.c b/ext/openssl/openssl.c index 4a9fcbc9e..59a58b1c0 100644 --- a/ext/openssl/openssl.c +++ b/ext/openssl/openssl.c @@ -4676,9 +4676,6 @@ SSL *php_SSL_new_from_context(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{ GET_VER_OPT_STRING("local_cert", certfile); if (certfile) { - X509 *cert = NULL; - EVP_PKEY *key = NULL; - SSL *tmpssl; char resolved_path_buff[MAXPATHLEN]; const char * private_key = NULL; @@ -4705,16 +4702,22 @@ SSL *php_SSL_new_from_context(SSL_CTX *ctx, php_stream *stream TSRMLS_DC) /* {{{ } } - tmpssl = SSL_new(ctx); - cert = SSL_get_certificate(tmpssl); - - if (cert) { - key = X509_get_pubkey(cert); - EVP_PKEY_copy_parameters(key, SSL_get_privatekey(tmpssl)); - EVP_PKEY_free(key); - } - SSL_free(tmpssl); - +#if OPENSSL_VERSION_NUMBER < 0x10001001L + do { + /* Unnecessary as of OpenSSLv1.0.1 (will segfault if used with >= 10001001 ) */ + X509 *cert = NULL; + EVP_PKEY *key = NULL; + SSL *tmpssl = SSL_new(ctx); + cert = SSL_get_certificate(tmpssl); + + if (cert) { + key = X509_get_pubkey(cert); + EVP_PKEY_copy_parameters(key, SSL_get_privatekey(tmpssl)); + EVP_PKEY_free(key); + } + SSL_free(tmpssl); + } while (0); +#endif if (!SSL_CTX_check_private_key(ctx)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Private key does not match certificate!"); } |