Skip to content

Commit 8be2a79

Browse files
committed
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(). ```
1 parent 2518eb8 commit 8be2a79

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/streams/openssl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ static int check_host_name(const char *name, const char *host)
332332

333333
static int verify_server_cert(SSL *ssl, const char *host)
334334
{
335-
X509 *cert;
335+
X509 *cert = NULL;
336336
X509_NAME *peer_name;
337337
ASN1_STRING *str;
338338
unsigned char *peer_cn = NULL;
@@ -458,6 +458,7 @@ static int verify_server_cert(SSL *ssl, const char *host)
458458
goto cleanup;
459459

460460
cleanup:
461+
X509_free(cert);
461462
OPENSSL_free(peer_cn);
462463
return error;
463464
}

0 commit comments

Comments
 (0)