diff options
| author | jsing <> | 2016-07-06 16:47:18 +0000 |
|---|---|---|
| committer | jsing <> | 2016-07-06 16:47:18 +0000 |
| commit | 4ee227cb929685f42853208d23f3ce28074c8902 (patch) | |
| tree | 739b0cfedd0745b76afc47ec1b60aba6e6dd77aa /src/lib/libtls/tls_config.c | |
| parent | 3803d219784b2a7ab1f3763c33bbe2be2c103c60 (diff) | |
| download | openbsd-4ee227cb929685f42853208d23f3ce28074c8902.tar.gz openbsd-4ee227cb929685f42853208d23f3ce28074c8902.tar.bz2 openbsd-4ee227cb929685f42853208d23f3ce28074c8902.zip | |
Check that the given ciphers string is syntactically valid and results in
at least one matching cipher suite.
ok doug@
Diffstat (limited to '')
| -rw-r--r-- | src/lib/libtls/tls_config.c | 18 |
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, | |||
| 339 | int | 339 | int |
| 340 | tls_config_set_ciphers(struct tls_config *config, const char *ciphers) | 340 | tls_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 | ||
| 353 | int | 369 | int |
