summaryrefslogtreecommitdiff
path: root/src/lib/libtls/tls.c
diff options
context:
space:
mode:
authorjsing <>2017-09-20 17:05:17 +0000
committerjsing <>2017-09-20 17:05:17 +0000
commit263609dd4f2b34a02f6d2e943f58b18b8eef887a (patch)
treef4080509dd8de2bb329aba671f06b4864aeec78e /src/lib/libtls/tls.c
parent8a110cc82bb2df37088502de9f15ac4c8fea6467 (diff)
downloadopenbsd-263609dd4f2b34a02f6d2e943f58b18b8eef887a.tar.gz
openbsd-263609dd4f2b34a02f6d2e943f58b18b8eef887a.tar.bz2
openbsd-263609dd4f2b34a02f6d2e943f58b18b8eef887a.zip
Keep track of which keypair is in use by a TLS context.
This fixes a bug where by a TLS server with SNI would always only return the OCSP staple for the default keypair, rather than returning the OCSP staple associated with the keypair that was selected via SNI. Issue reported by William Graeber and confirmed by Andreas Bartelt. Fix tested by William Graeber and Andreas Bartelt - thanks!
Diffstat (limited to 'src/lib/libtls/tls.c')
-rw-r--r--src/lib/libtls/tls.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/lib/libtls/tls.c b/src/lib/libtls/tls.c
index d4e8d0114f..f07c4c6deb 100644
--- a/src/lib/libtls/tls.c
+++ b/src/lib/libtls/tls.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls.c,v 1.70 2017/08/28 13:58:02 beck Exp $ */ 1/* $OpenBSD: tls.c,v 1.71 2017/09/20 17:05:17 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -235,6 +235,7 @@ tls_new(void)
235 return (NULL); 235 return (NULL);
236 236
237 tls_reset(ctx); 237 tls_reset(ctx);
238
238 if (tls_configure(ctx, tls_config_default) == -1) { 239 if (tls_configure(ctx, tls_config_default) == -1) {
239 free(ctx); 240 free(ctx);
240 return NULL; 241 return NULL;
@@ -252,7 +253,9 @@ tls_configure(struct tls *ctx, struct tls_config *config)
252 config->refcount++; 253 config->refcount++;
253 254
254 tls_config_free(ctx->config); 255 tls_config_free(ctx->config);
256
255 ctx->config = config; 257 ctx->config = config;
258 ctx->keypair = config->keypair;
256 259
257 if ((ctx->flags & TLS_SERVER) != 0) 260 if ((ctx->flags & TLS_SERVER) != 0)
258 return (tls_configure_server(ctx)); 261 return (tls_configure_server(ctx));