Commit 8be2a790 by Etienne Samson

openssl: free the peer certificate

Per SSL_get_peer_certificate docs:
```
The reference count of the X509 object is incremented by one, so that it will not be destroyed when the session containing the peer certificate is freed. The X509 object must be explicitly freed using X509_free().
```
parent 2518eb81
...@@ -332,7 +332,7 @@ static int check_host_name(const char *name, const char *host) ...@@ -332,7 +332,7 @@ static int check_host_name(const char *name, const char *host)
static int verify_server_cert(SSL *ssl, const char *host) static int verify_server_cert(SSL *ssl, const char *host)
{ {
X509 *cert; X509 *cert = NULL;
X509_NAME *peer_name; X509_NAME *peer_name;
ASN1_STRING *str; ASN1_STRING *str;
unsigned char *peer_cn = NULL; unsigned char *peer_cn = NULL;
...@@ -458,6 +458,7 @@ on_error: ...@@ -458,6 +458,7 @@ on_error:
goto cleanup; goto cleanup;
cleanup: cleanup:
X509_free(cert);
OPENSSL_free(peer_cn); OPENSSL_free(peer_cn);
return error; return error;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment