summaryrefslogtreecommitdiff
path: root/src/lib/libtls/tls_client.c
diff options
context:
space:
mode:
authorbcook <>2014-12-07 15:00:32 +0000
committerbcook <>2014-12-07 15:00:32 +0000
commitf8b7419c7a231d8409475ccb008dfdb666e82813 (patch)
tree094ce4813a37514a96f893ee676a60374f36f28b /src/lib/libtls/tls_client.c
parent54c29dc63f86eb85f4c728ad9b5375acc16f8ea7 (diff)
downloadopenbsd-f8b7419c7a231d8409475ccb008dfdb666e82813.tar.gz
openbsd-f8b7419c7a231d8409475ccb008dfdb666e82813.tar.bz2
openbsd-f8b7419c7a231d8409475ccb008dfdb666e82813.zip
Allow specific libtls hostname validation errors to propagate.
Remove direct calls to printf from the tls_check_hostname() path. This allows NUL byte error messages to bubble up to the caller, to be logged in a program-appropriate way. It also removes non-portable calls to getprogname(). The semantics of tls_error() are changed slightly: the last error message is not necessarily preserved between subsequent calls into the library. When the previous call to libtls succeeds, client programs should treat the return value of tls_error() as undefined. ok tedu@
Diffstat (limited to 'src/lib/libtls/tls_client.c')
-rw-r--r--src/lib/libtls/tls_client.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/libtls/tls_client.c b/src/lib/libtls/tls_client.c
index a4528b9b87..c5849a6897 100644
--- a/src/lib/libtls/tls_client.c
+++ b/src/lib/libtls/tls_client.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_client.c,v 1.2 2014/11/02 14:45:05 jsing Exp $ */ 1/* $OpenBSD: tls_client.c,v 1.3 2014/12/07 15:00:32 bcook Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2014 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -209,9 +209,11 @@ tls_connect_fds(struct tls *ctx, int fd_read, int fd_write,
209 tls_set_error(ctx, "no server certificate"); 209 tls_set_error(ctx, "no server certificate");
210 goto err; 210 goto err;
211 } 211 }
212 if (tls_check_hostname(cert, hostname) != 0) { 212 tls_clear_error(ctx);
213 tls_set_error(ctx, "host `%s' not present in" 213 if (tls_check_hostname(ctx, cert, hostname) != 0) {
214 " server certificate", hostname); 214 if (tls_error(ctx) == NULL)
215 tls_set_error(ctx, "host `%s' not present in"
216 " server certificate", hostname);
215 goto err; 217 goto err;
216 } 218 }
217 } 219 }