summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjsing <>2017-01-03 17:19:57 +0000
committerjsing <>2017-01-03 17:19:57 +0000
commitfd81cf8bba7723f40b391937f8ff671f2526d90c (patch)
tree64d170100d7b795db8a0cd423ce48db0f2567cbe
parent6070037b9b7f8d391060efcb8e1123ff682da427 (diff)
downloadopenbsd-fd81cf8bba7723f40b391937f8ff671f2526d90c.tar.gz
openbsd-fd81cf8bba7723f40b391937f8ff671f2526d90c.tar.bz2
openbsd-fd81cf8bba7723f40b391937f8ff671f2526d90c.zip
If certificate verification has been disabled, do not attempt to load a
CA chain or specify CA paths. This prevents attempts to access the file system, which may fail due to pledge. ok bluhm@
-rw-r--r--src/lib/libtls/tls.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/lib/libtls/tls.c b/src/lib/libtls/tls.c
index e192942b6b..c85e5449d8 100644
--- a/src/lib/libtls/tls.c
+++ b/src/lib/libtls/tls.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls.c,v 1.55 2017/01/03 17:13:41 jsing Exp $ */ 1/* $OpenBSD: tls.c,v 1.56 2017/01/03 17:19:57 jsing Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -398,6 +398,13 @@ tls_configure_ssl_verify(struct tls *ctx, SSL_CTX *ssl_ctx, int verify)
398 int rv = -1; 398 int rv = -1;
399 399
400 SSL_CTX_set_verify(ssl_ctx, verify, NULL); 400 SSL_CTX_set_verify(ssl_ctx, verify, NULL);
401 SSL_CTX_set_cert_verify_callback(ssl_ctx, tls_ssl_cert_verify_cb, ctx);
402
403 if (ctx->config->verify_depth >= 0)
404 SSL_CTX_set_verify_depth(ssl_ctx, ctx->config->verify_depth);
405
406 if (ctx->config->verify_cert == 0)
407 goto done;
401 408
402 /* If no CA has been specified, attempt to load the default. */ 409 /* If no CA has been specified, attempt to load the default. */
403 if (ctx->config->ca_mem == NULL && ctx->config->ca_path == NULL) { 410 if (ctx->config->ca_mem == NULL && ctx->config->ca_path == NULL) {
@@ -421,11 +428,8 @@ tls_configure_ssl_verify(struct tls *ctx, SSL_CTX *ssl_ctx, int verify)
421 tls_set_errorx(ctx, "ssl verify locations failure"); 428 tls_set_errorx(ctx, "ssl verify locations failure");
422 goto err; 429 goto err;
423 } 430 }
424 if (ctx->config->verify_depth >= 0)
425 SSL_CTX_set_verify_depth(ssl_ctx, ctx->config->verify_depth);
426
427 SSL_CTX_set_cert_verify_callback(ssl_ctx, tls_ssl_cert_verify_cb, ctx);
428 431
432 done:
429 rv = 0; 433 rv = 0;
430 434
431 err: 435 err: