diff src/http/ngx_http_request.c @ 1974:f32cc6df6bd6

fix memory leak when ssl_verify_client is on
author Igor Sysoev <igor@sysoev.ru>
date Wed, 23 Apr 2008 18:57:25 +0000
parents 291689a7e5dc
children 38fa1d3a31b7 72b09c4dd8f7
line wrap: on
line diff
--- a/src/http/ngx_http_request.c
+++ b/src/http/ngx_http_request.c
@@ -1419,6 +1419,7 @@ ngx_http_process_request(ngx_http_reques
 
     if (c->ssl) {
         long                      rc;
+        X509                     *cert;
         ngx_http_ssl_srv_conf_t  *sscf;
 
         sscf = ngx_http_get_module_srv_conf(r, ngx_http_ssl_module);
@@ -1438,9 +1439,9 @@ ngx_http_process_request(ngx_http_reques
                 return;
             }
 
-            if (SSL_get_peer_certificate(c->ssl->connection)
-                == NULL)
-            {
+            cert = SSL_get_peer_certificate(c->ssl->connection);
+
+            if (cert == NULL) {
                 ngx_log_error(NGX_LOG_INFO, c->log, 0,
                               "client sent no required SSL certificate");
 
@@ -1450,6 +1451,8 @@ ngx_http_process_request(ngx_http_reques
                 ngx_http_finalize_request(r, NGX_HTTPS_NO_CERT);
                 return;
             }
+
+            X509_free(cert);
         }
     }