summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorjsing <>2016-07-06 16:47:18 +0000
committerjsing <>2016-07-06 16:47:18 +0000
commitc9e35f43e12c7641ab7767b141f1948129ae72c9 (patch)
tree739b0cfedd0745b76afc47ec1b60aba6e6dd77aa /src/lib
parentff841a7f5640cf43d804a47ee366975efc00dffe (diff)
downloadopenbsd-c9e35f43e12c7641ab7767b141f1948129ae72c9.tar.gz
openbsd-c9e35f43e12c7641ab7767b141f1948129ae72c9.tar.bz2
openbsd-c9e35f43e12c7641ab7767b141f1948129ae72c9.zip
Check that the given ciphers string is syntactically valid and results in
at least one matching cipher suite. ok doug@
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libtls/tls_config.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/lib/libtls/tls_config.c b/src/lib/libtls/tls_config.c
index cfd054b024..a348b826d5 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.19 2016/07/06 16:16:36 jsing Exp $ */ 1/* $OpenBSD: tls_config.c,v 1.20 2016/07/06 16:47:18 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -339,6 +339,8 @@ tls_config_set_cert_mem(struct tls_config *config, const uint8_t *cert,
339int 339int
340tls_config_set_ciphers(struct tls_config *config, const char *ciphers) 340tls_config_set_ciphers(struct tls_config *config, const char *ciphers)
341{ 341{
342 SSL_CTX *ssl_ctx = NULL;
343
342 if (ciphers == NULL || 344 if (ciphers == NULL ||
343 strcasecmp(ciphers, "default") == 0 || 345 strcasecmp(ciphers, "default") == 0 ||
344 strcasecmp(ciphers, "secure") == 0) 346 strcasecmp(ciphers, "secure") == 0)
@@ -347,7 +349,21 @@ tls_config_set_ciphers(struct tls_config *config, const char *ciphers)
347 strcasecmp(ciphers, "legacy") == 0) 349 strcasecmp(ciphers, "legacy") == 0)
348 ciphers = TLS_CIPHERS_COMPAT; 350 ciphers = TLS_CIPHERS_COMPAT;
349 351
352 if ((ssl_ctx = SSL_CTX_new(SSLv23_method())) == NULL) {
353 tls_config_set_errorx(config, "out of memory");
354 goto fail;
355 }
356 if (SSL_CTX_set_cipher_list(ssl_ctx, ciphers) != 1) {
357 tls_config_set_errorx(config, "no ciphers for '%s'", ciphers);
358 goto fail;
359 }
360
361 SSL_CTX_free(ssl_ctx);
350 return set_string(&config->ciphers, ciphers); 362 return set_string(&config->ciphers, ciphers);
363
364 fail:
365 SSL_CTX_free(ssl_ctx);
366 return -1;
351} 367}
352 368
353int 369int