diff options
author | beck <> | 2017-01-29 17:52:11 +0000 |
---|---|---|
committer | beck <> | 2017-01-29 17:52:11 +0000 |
commit | a2ee48f27a063262b94d5f6eb321659dc22d4146 (patch) | |
tree | 87cead16195a1077918bc769c77b847b69cfdf34 /src/lib/libtls/tls_config.c | |
parent | 957b11334a7afb14537322f0e4795b2e368b3f59 (diff) | |
download | openbsd-a2ee48f27a063262b94d5f6eb321659dc22d4146.tar.gz openbsd-a2ee48f27a063262b94d5f6eb321659dc22d4146.tar.bz2 openbsd-a2ee48f27a063262b94d5f6eb321659dc22d4146.zip |
Move the ocsp staple to being part of the keypair structure internally,
so that it does not send back bogus staples when SNI is in use.
(Further change is required to be able to use staples on all keypairs
and not just the main one)
ok jsing@
Diffstat (limited to 'src/lib/libtls/tls_config.c')
-rw-r--r-- | src/lib/libtls/tls_config.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/lib/libtls/tls_config.c b/src/lib/libtls/tls_config.c index 8fa810461c..83c649fd51 100644 --- a/src/lib/libtls/tls_config.c +++ b/src/lib/libtls/tls_config.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: tls_config.c,v 1.34 2017/01/24 01:48:05 claudio Exp $ */ | 1 | /* $OpenBSD: tls_config.c,v 1.35 2017/01/29 17:52:11 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> | 3 | * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> |
4 | * | 4 | * |
@@ -101,6 +101,22 @@ tls_keypair_set_key_mem(struct tls_keypair *keypair, const uint8_t *key, | |||
101 | return set_mem(&keypair->key_mem, &keypair->key_len, key, len); | 101 | return set_mem(&keypair->key_mem, &keypair->key_len, key, len); |
102 | } | 102 | } |
103 | 103 | ||
104 | static int | ||
105 | tls_keypair_set_ocsp_staple_file(struct tls_keypair *keypair, | ||
106 | struct tls_error *error, const char *ocsp_file) | ||
107 | { | ||
108 | return tls_config_load_file(error, "ocsp", ocsp_file, | ||
109 | &keypair->ocsp_staple, &keypair->ocsp_staple_len); | ||
110 | } | ||
111 | |||
112 | static int | ||
113 | tls_keypair_set_ocsp_staple_mem(struct tls_keypair *keypair, | ||
114 | const uint8_t *staple, size_t len) | ||
115 | { | ||
116 | return set_mem(&keypair->ocsp_staple, &keypair->ocsp_staple_len, staple, | ||
117 | len); | ||
118 | } | ||
119 | |||
104 | static void | 120 | static void |
105 | tls_keypair_clear(struct tls_keypair *keypair) | 121 | tls_keypair_clear(struct tls_keypair *keypair) |
106 | { | 122 | { |
@@ -118,6 +134,7 @@ tls_keypair_free(struct tls_keypair *keypair) | |||
118 | 134 | ||
119 | free(keypair->cert_mem); | 135 | free(keypair->cert_mem); |
120 | free(keypair->key_mem); | 136 | free(keypair->key_mem); |
137 | free(keypair->ocsp_staple); | ||
121 | 138 | ||
122 | free(keypair); | 139 | free(keypair); |
123 | } | 140 | } |
@@ -241,7 +258,6 @@ tls_config_free(struct tls_config *config) | |||
241 | free((char *)config->ca_mem); | 258 | free((char *)config->ca_mem); |
242 | free((char *)config->ca_path); | 259 | free((char *)config->ca_path); |
243 | free((char *)config->ciphers); | 260 | free((char *)config->ciphers); |
244 | free(config->ocsp_staple); | ||
245 | 261 | ||
246 | free(config); | 262 | free(config); |
247 | } | 263 | } |
@@ -664,14 +680,14 @@ tls_config_verify_client_optional(struct tls_config *config) | |||
664 | int | 680 | int |
665 | tls_config_set_ocsp_staple_file(struct tls_config *config, const char *staple_file) | 681 | tls_config_set_ocsp_staple_file(struct tls_config *config, const char *staple_file) |
666 | { | 682 | { |
667 | return tls_config_load_file(&config->error, "OCSP", staple_file, | 683 | return tls_keypair_set_ocsp_staple_file(config->keypair, &config->error, |
668 | &config->ocsp_staple, &config->ocsp_staple_len); | 684 | staple_file); |
669 | } | 685 | } |
670 | 686 | ||
671 | int | 687 | int |
672 | tls_config_set_ocsp_staple_mem(struct tls_config *config, char *staple, size_t len) | 688 | tls_config_set_ocsp_staple_mem(struct tls_config *config, char *staple, size_t len) |
673 | { | 689 | { |
674 | return set_mem(&config->ocsp_staple, &config->ocsp_staple_len, staple, len); | 690 | return tls_keypair_set_ocsp_staple_mem(config->keypair, staple, len); |
675 | } | 691 | } |
676 | 692 | ||
677 | int | 693 | int |