cvs: php-src /ext/openssl openssl.c
| From: | Ilia Alshanetsky | Date: | Tue, 14 Oct 2008 23:39:02 +0000 |
| Subject: | cvs: php-src /ext/openssl openssl.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-53520@lists.php.net to get a copy of this message | ||
iliaa Tue Oct 14 23:39:02 2008 UTC
Modified files:
/php-src/ext/openssl openssl.c
Log:
MFB: Fixed bug #46271 (local_cert option is not resolved to full path)
http://cvs.php.net/viewvc.cgi/php-src/ext/openssl/openssl.c?r1=1.169&r2=1.170&diff_format=u
Index: php-src/ext/openssl/openssl.c
diff -u php-src/ext/openssl/openssl.c:1.169 php-src/ext/openssl/openssl.c:1.170
--- php-src/ext/openssl/openssl.c:1.169 Tue Sep 30 14:40:58 2008
+++ php-src/ext/openssl/openssl.c Tue Oct 14 23:39:02 2008
@@ -20,7 +20,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: openssl.c,v 1.169 2008/09/30 14:40:58 rrichards Exp $ */
+/* $Id: openssl.c,v 1.170 2008/10/14 23:39:02 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -4700,30 +4700,33 @@
X509 *cert = NULL;
EVP_PKEY *key = NULL;
SSL *tmpssl;
+ char resolved_path_buff[MAXPATHLEN];
- /* a certificate to use for authentication */
- if (SSL_CTX_use_certificate_chain_file(ctx, certfile) != 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set local cert chain file `%s';
Check that your cafile/capath settings include details of your certificate and its issuer",
certfile);
- return NULL;
- }
+ if (VCWD_REALPATH(certfile, resolved_path_buff)) {
+ /* a certificate to use for authentication */
+ if (SSL_CTX_use_certificate_chain_file(ctx, resolved_path_buff) != 1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set local cert chain file
`%s'; Check that your cafile/capath settings include details of your certificate and its
issuer", certfile);
+ return NULL;
+ }
- if (SSL_CTX_use_PrivateKey_file(ctx, certfile, SSL_FILETYPE_PEM) != 1) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set private key file
`%s'", certfile);
- return NULL;
- }
+ if (SSL_CTX_use_PrivateKey_file(ctx, resolved_path_buff, SSL_FILETYPE_PEM) != 1) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Unable to set private key file
`%s'", resolved_path_buff);
+ return NULL;
+ }
- tmpssl = SSL_new(ctx);
- cert = SSL_get_certificate(tmpssl);
+ 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 (cert) {
+ key = X509_get_pubkey(cert);
+ EVP_PKEY_copy_parameters(key, SSL_get_privatekey(tmpssl));
+ EVP_PKEY_free(key);
+ }
+ SSL_free(tmpssl);
- if (!SSL_CTX_check_private_key(ctx)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Private key does not match
certificate!");
+ if (!SSL_CTX_check_private_key(ctx)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Private key does not match
certificate!");
+ }
}
}
if (ok) {