diff options
author | bcook <> | 2016-09-20 04:25:09 +0000 |
---|---|---|
committer | bcook <> | 2016-09-20 04:25:09 +0000 |
commit | 3b6b56730116702a5227185bcb75e65c5a8b014d (patch) | |
tree | a06be3d99c665826951a3407061d026fe150285e /src | |
parent | 4d329ef68ffc2c4341e5dd2d8d241e87c17d4ca1 (diff) | |
download | openbsd-3b6b56730116702a5227185bcb75e65c5a8b014d.tar.gz openbsd-3b6b56730116702a5227185bcb75e65c5a8b014d.tar.bz2 openbsd-3b6b56730116702a5227185bcb75e65c5a8b014d.zip |
Avoid selecting weak digests for (EC)DH when using SNI.
from OpenSSL:
SSL_set_SSL_CTX is normally called for SNI after ClientHello has
received and the digest to use for each certificate has been decided.
The original ssl->cert contains the negotiated digests and is now
copied to the new ssl->cert.
noted by David Benjamin and Kinichiro Inoguchi
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libssl/ssl_lib.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lib/libssl/ssl_lib.c b/src/lib/libssl/ssl_lib.c index 5b9b952e72..59a90d4b8e 100644 --- a/src/lib/libssl/ssl_lib.c +++ b/src/lib/libssl/ssl_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_lib.c,v 1.116 2015/10/25 15:52:49 doug Exp $ */ | 1 | /* $OpenBSD: ssl_lib.c,v 1.117 2016/09/20 04:25:09 bcook Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -2847,13 +2847,22 @@ SSL_get_SSL_CTX(const SSL *ssl) | |||
2847 | SSL_CTX * | 2847 | SSL_CTX * |
2848 | SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx) | 2848 | SSL_set_SSL_CTX(SSL *ssl, SSL_CTX* ctx) |
2849 | { | 2849 | { |
2850 | CERT *ocert = ssl->cert; | ||
2850 | if (ssl->ctx == ctx) | 2851 | if (ssl->ctx == ctx) |
2851 | return (ssl->ctx); | 2852 | return (ssl->ctx); |
2852 | if (ctx == NULL) | 2853 | if (ctx == NULL) |
2853 | ctx = ssl->initial_ctx; | 2854 | ctx = ssl->initial_ctx; |
2854 | if (ssl->cert != NULL) | ||
2855 | ssl_cert_free(ssl->cert); | ||
2856 | ssl->cert = ssl_cert_dup(ctx->cert); | 2855 | ssl->cert = ssl_cert_dup(ctx->cert); |
2856 | if (ocert != NULL) { | ||
2857 | int i; | ||
2858 | /* Copy negotiated digests from original */ | ||
2859 | for (i = 0; i < SSL_PKEY_NUM; i++) { | ||
2860 | CERT_PKEY *cpk = ocert->pkeys + i; | ||
2861 | CERT_PKEY *rpk = ssl->cert->pkeys + i; | ||
2862 | rpk->digest = cpk->digest; | ||
2863 | } | ||
2864 | ssl_cert_free(ocert); | ||
2865 | } | ||
2857 | CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); | 2866 | CRYPTO_add(&ctx->references, 1, CRYPTO_LOCK_SSL_CTX); |
2858 | SSL_CTX_free(ssl->ctx); /* decrement reference count */ | 2867 | SSL_CTX_free(ssl->ctx); /* decrement reference count */ |
2859 | ssl->ctx = ctx; | 2868 | ssl->ctx = ctx; |