Codebase list openssl / c645f9d
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/3426) Matt Caswell 7 years ago
3 changed file(s) with 27 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
33923392 if (new_cert == NULL) {
33933393 return NULL;
33943394 }
3395
3396 if (!custom_exts_copy_flags(&new_cert->srv_ext, &ssl->cert->srv_ext)) {
3397 ssl_cert_free(new_cert);
3398 return NULL;
3399 }
3400
33953401 ssl_cert_free(ssl->cert);
33963402 ssl->cert = new_cert;
33973403
21162116
21172117 __owur int custom_exts_copy(custom_ext_methods *dst,
21182118 const custom_ext_methods *src);
2119 __owur int custom_exts_copy_flags(custom_ext_methods *dst,
2120 const custom_ext_methods *src);
21192121 void custom_exts_free(custom_ext_methods *exts);
21202122
21212123 void ssl_comp_free_compression_methods_int(void);
127127 meth->free_cb(s, meth->ext_type, out, meth->add_arg);
128128 }
129129 *pret = ret;
130 return 1;
131 }
132
133 /* Copy the flags from src to dst for any extensions that exist in both */
134 int custom_exts_copy_flags(custom_ext_methods *dst,
135 const custom_ext_methods *src)
136 {
137 size_t i;
138 custom_ext_method *methsrc = src->meths;
139
140 for (i = 0; i < src->meths_count; i++, methsrc++) {
141 custom_ext_method *methdst = custom_ext_find(dst, methsrc->ext_type);
142
143 if (methdst == NULL)
144 continue;
145
146 methdst->ext_flags = methsrc->ext_flags;
147 }
148
130149 return 1;
131150 }
132151