summaryrefslogtreecommitdiffstats
path: root/ssl/statem/extensions_cust.c
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2017-05-10 11:28:53 +0100
committerMatt Caswell <matt@openssl.org>2017-05-10 16:49:00 +0100
commit21181889d78f95f10738813285f681acd3b32c6c (patch)
treec5ff13183d4986cba98218d581eafcdeeb0163da /ssl/statem/extensions_cust.c
parentcf53cbea5bbf9c3a1998e2ddd0173881a5a97475 (diff)
Copy custom extension flags in a call to SSL_set_SSL_CTX()
The function SSL_set_SSL_CTX() can be used to swap the SSL_CTX used for a connection as part of an SNI callback. One result of this is that the s->cert structure is replaced. However this structure contains information about any custom extensions that have been loaded. In particular flags are set indicating whether a particular extension has been received in the ClientHello. By replacing the s->cert structure we lose the custom extension flag values, and it appears as if a client has not sent those extensions. SSL_set_SSL_CTX() should copy any flags for custom extensions that appear in both the old and the new cert structure. Fixes #2180 Reviewed-by: Rich Salz <rsalz@openssl.org> (Merged from https://github.com/openssl/openssl/pull/3425)
Diffstat (limited to 'ssl/statem/extensions_cust.c')
-rw-r--r--ssl/statem/extensions_cust.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/ssl/statem/extensions_cust.c b/ssl/statem/extensions_cust.c
index 2a21ec492c..e06fa9d1d7 100644
--- a/ssl/statem/extensions_cust.c
+++ b/ssl/statem/extensions_cust.c
@@ -231,6 +231,26 @@ int custom_ext_add(SSL *s, int context, WPACKET *pkt, X509 *x, size_t chainidx,
return 1;
}
+/* Copy the flags from src to dst for any extensions that exist in both */
+int custom_exts_copy_flags(custom_ext_methods *dst,
+ const custom_ext_methods *src)
+{
+ size_t i;
+ custom_ext_method *methsrc = src->meths;
+
+ for (i = 0; i < src->meths_count; i++, methsrc++) {
+ custom_ext_method *methdst = custom_ext_find(dst, methsrc->role,
+ methsrc->ext_type, NULL);
+
+ if (methdst == NULL)
+ continue;
+
+ methdst->ext_flags = methsrc->ext_flags;
+ }
+
+ return 1;
+}
+
/* Copy table of custom extensions */
int custom_exts_copy(custom_ext_methods *dst, const custom_ext_methods *src)
{