summaryrefslogtreecommitdiff
path: root/src/lib/libtls/tls.c
diff options
context:
space:
mode:
authorjsing <>2017-06-22 18:03:57 +0000
committerjsing <>2017-06-22 18:03:57 +0000
commit90062b095bce6ad54ec2645782fc8fb9c66c8d1a (patch)
treefd55783db0a8125ddd4a355217eca79710738964 /src/lib/libtls/tls.c
parent76ff5fe336f69e4da4140cc2ea4324229e3fc762 (diff)
downloadopenbsd-90062b095bce6ad54ec2645782fc8fb9c66c8d1a.tar.gz
openbsd-90062b095bce6ad54ec2645782fc8fb9c66c8d1a.tar.bz2
openbsd-90062b095bce6ad54ec2645782fc8fb9c66c8d1a.zip
Use the tls_password_cb() callback with all PEM_read_bio_*() calls, so that
we can prevent libcrypto from going behind our back and trying to read passwords from standard input (which we may not be permitted to do). Found by jsg@ with httpd and password protected keys.
Diffstat (limited to 'src/lib/libtls/tls.c')
-rw-r--r--src/lib/libtls/tls.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/lib/libtls/tls.c b/src/lib/libtls/tls.c
index b75fae7f2b..f64f6d7632 100644
--- a/src/lib/libtls/tls.c
+++ b/src/lib/libtls/tls.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls.c,v 1.66 2017/06/22 17:58:54 jsing Exp $ */ 1/* $OpenBSD: tls.c,v 1.67 2017/06/22 18:03: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 *
@@ -289,11 +289,11 @@ tls_keypair_cert_hash(struct tls_keypair *keypair, char **hash)
289 289
290 *hash = NULL; 290 *hash = NULL;
291 291
292 if ((membio = BIO_new_mem_buf(keypair->cert_mem, keypair->cert_len)) 292 if ((membio = BIO_new_mem_buf(keypair->cert_mem,
293 == NULL) 293 keypair->cert_len)) == NULL)
294 goto err; 294 goto err;
295 295 if ((cert = PEM_read_bio_X509_AUX(membio, NULL, tls_password_cb,
296 if ((cert = PEM_read_bio_X509_AUX(membio, NULL, NULL, NULL)) == NULL) 296 NULL)) == NULL)
297 goto err; 297 goto err;
298 298
299 rv = tls_cert_hash(cert, hash); 299 rv = tls_cert_hash(cert, hash);
@@ -344,7 +344,7 @@ tls_configure_ssl_keypair(struct tls *ctx, SSL_CTX *ssl_ctx,
344 tls_set_errorx(ctx, "failed to create buffer"); 344 tls_set_errorx(ctx, "failed to create buffer");
345 goto err; 345 goto err;
346 } 346 }
347 if ((pkey = PEM_read_bio_PrivateKey(bio, NULL, NULL, 347 if ((pkey = PEM_read_bio_PrivateKey(bio, NULL, tls_password_cb,
348 NULL)) == NULL) { 348 NULL)) == NULL) {
349 tls_set_errorx(ctx, "failed to read private key"); 349 tls_set_errorx(ctx, "failed to read private key");
350 goto err; 350 goto err;