summaryrefslogtreecommitdiff
path: root/src/lib/libtls/tls_server.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_server.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_server.c')
-rw-r--r--src/lib/libtls/tls_server.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/lib/libtls/tls_server.c b/src/lib/libtls/tls_server.c
index ea8f0ce728..fd5a617582 100644
--- a/src/lib/libtls/tls_server.c
+++ b/src/lib/libtls/tls_server.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_server.c,v 1.38 2017/06/22 17:34:25 jsing Exp $ */ 1/* $OpenBSD: tls_server.c,v 1.39 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 *
@@ -215,7 +215,8 @@ tls_keypair_load_cert(struct tls_keypair *keypair, struct tls_error *error,
215 tls_error_set(error, "failed to create certificate bio"); 215 tls_error_set(error, "failed to create certificate bio");
216 goto err; 216 goto err;
217 } 217 }
218 if ((*cert = PEM_read_bio_X509(cert_bio, NULL, NULL, NULL)) == NULL) { 218 if ((*cert = PEM_read_bio_X509(cert_bio, NULL, tls_password_cb,
219 NULL)) == NULL) {
219 if ((ssl_err = ERR_peek_error()) != 0) 220 if ((ssl_err = ERR_peek_error()) != 0)
220 errstr = ERR_error_string(ssl_err, NULL); 221 errstr = ERR_error_string(ssl_err, NULL);
221 tls_error_set(error, "failed to load certificate: %s", errstr); 222 tls_error_set(error, "failed to load certificate: %s", errstr);