diff options
author | jsing <> | 2015-09-11 09:24:54 +0000 |
---|---|---|
committer | jsing <> | 2015-09-11 09:24:54 +0000 |
commit | 4a7d1a83580ba9a10df254d6df03a0bc3d8fa726 (patch) | |
tree | e3436a497fd181c2834939f8783f7714c0b44960 /src | |
parent | b0404dc3aed5b42933d7f9650d2a9f6e0620f34c (diff) | |
download | openbsd-4a7d1a83580ba9a10df254d6df03a0bc3d8fa726.tar.gz openbsd-4a7d1a83580ba9a10df254d6df03a0bc3d8fa726.tar.bz2 openbsd-4a7d1a83580ba9a10df254d6df03a0bc3d8fa726.zip |
Store a reference to the peer certificate (if any) upon completion of the
handshake. Free the reference when we reset the TLS context.
ok beck@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libtls/tls.c | 7 | ||||
-rw-r--r-- | src/lib/libtls/tls_internal.h | 3 |
2 files changed, 8 insertions, 2 deletions
diff --git a/src/lib/libtls/tls.c b/src/lib/libtls/tls.c index 282f68edf6..aa49641ab2 100644 --- a/src/lib/libtls/tls.c +++ b/src/lib/libtls/tls.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls.c,v 1.24 2015/09/10 18:43:03 jsing Exp $ */ | 1 | /* $OpenBSD: tls.c,v 1.25 2015/09/11 09:24:54 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -308,9 +308,11 @@ tls_reset(struct tls *ctx) | |||
308 | { | 308 | { |
309 | SSL_CTX_free(ctx->ssl_ctx); | 309 | SSL_CTX_free(ctx->ssl_ctx); |
310 | SSL_free(ctx->ssl_conn); | 310 | SSL_free(ctx->ssl_conn); |
311 | X509_free(ctx->ssl_peer_cert); | ||
311 | 312 | ||
312 | ctx->ssl_conn = NULL; | 313 | ctx->ssl_conn = NULL; |
313 | ctx->ssl_ctx = NULL; | 314 | ctx->ssl_ctx = NULL; |
315 | ctx->ssl_peer_cert = NULL; | ||
314 | 316 | ||
315 | ctx->socket = -1; | 317 | ctx->socket = -1; |
316 | ctx->state = 0; | 318 | ctx->state = 0; |
@@ -379,6 +381,9 @@ tls_handshake(struct tls *ctx) | |||
379 | else if ((ctx->flags & TLS_SERVER_CONN) != 0) | 381 | else if ((ctx->flags & TLS_SERVER_CONN) != 0) |
380 | rv = tls_handshake_server(ctx); | 382 | rv = tls_handshake_server(ctx); |
381 | 383 | ||
384 | if (rv == 0) | ||
385 | ctx->ssl_peer_cert = SSL_get_peer_certificate(ctx->ssl_conn); | ||
386 | |||
382 | /* Prevent callers from performing incorrect error handling */ | 387 | /* Prevent callers from performing incorrect error handling */ |
383 | errno = 0; | 388 | errno = 0; |
384 | return (rv); | 389 | return (rv); |
diff --git a/src/lib/libtls/tls_internal.h b/src/lib/libtls/tls_internal.h index a5399d5594..b514847cfe 100644 --- a/src/lib/libtls/tls_internal.h +++ b/src/lib/libtls/tls_internal.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls_internal.h,v 1.18 2015/09/10 10:14:20 jsing Exp $ */ | 1 | /* $OpenBSD: tls_internal.h,v 1.19 2015/09/11 09:24:54 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> | 3 | * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> |
4 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 4 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
@@ -67,6 +67,7 @@ struct tls { | |||
67 | 67 | ||
68 | SSL *ssl_conn; | 68 | SSL *ssl_conn; |
69 | SSL_CTX *ssl_ctx; | 69 | SSL_CTX *ssl_ctx; |
70 | X509 *ssl_peer_cert; | ||
70 | }; | 71 | }; |
71 | 72 | ||
72 | struct tls *tls_new(void); | 73 | struct tls *tls_new(void); |