diff options
-rw-r--r-- | src/usr.bin/nc/netcat.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/usr.bin/nc/netcat.c b/src/usr.bin/nc/netcat.c index a9e2910089..dec23305a7 100644 --- a/src/usr.bin/nc/netcat.c +++ b/src/usr.bin/nc/netcat.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: netcat.c,v 1.214 2020/01/06 19:39:58 bluhm Exp $ */ | 1 | /* $OpenBSD: netcat.c,v 1.215 2020/01/07 17:36:04 bluhm Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> | 3 | * Copyright (c) 2001 Eric Jackson <ericj@monkey.org> |
4 | * Copyright (c) 2015 Bob Beck. All rights reserved. | 4 | * Copyright (c) 2015 Bob Beck. All rights reserved. |
@@ -835,8 +835,8 @@ tls_setup_client(struct tls *tls_ctx, int s, char *host) | |||
835 | } | 835 | } |
836 | if (vflag) | 836 | if (vflag) |
837 | report_tls(tls_ctx, host); | 837 | report_tls(tls_ctx, host); |
838 | if (tls_expecthash && tls_peer_cert_hash(tls_ctx) && | 838 | if (tls_expecthash && (tls_peer_cert_hash(tls_ctx) == NULL || |
839 | strcmp(tls_expecthash, tls_peer_cert_hash(tls_ctx)) != 0) | 839 | strcmp(tls_expecthash, tls_peer_cert_hash(tls_ctx)) != 0)) |
840 | errx(1, "peer certificate is not %s", tls_expecthash); | 840 | errx(1, "peer certificate is not %s", tls_expecthash); |
841 | if (Zflag) { | 841 | if (Zflag) { |
842 | save_peer_cert(tls_ctx, Zflag); | 842 | save_peer_cert(tls_ctx, Zflag); |
@@ -864,8 +864,9 @@ tls_setup_server(struct tls *tls_ctx, int connfd, char *host) | |||
864 | report_tls(tls_cctx, host); | 864 | report_tls(tls_cctx, host); |
865 | if ((TLSopt & TLS_CCERT) && !gotcert) | 865 | if ((TLSopt & TLS_CCERT) && !gotcert) |
866 | warnx("No client certificate provided"); | 866 | warnx("No client certificate provided"); |
867 | else if (gotcert && tls_peer_cert_hash(tls_ctx) && tls_expecthash && | 867 | else if (gotcert && tls_expecthash && |
868 | strcmp(tls_expecthash, tls_peer_cert_hash(tls_ctx)) != 0) | 868 | (tls_peer_cert_hash(tls_cctx) == NULL || |
869 | strcmp(tls_expecthash, tls_peer_cert_hash(tls_cctx)) != 0)) | ||
869 | warnx("peer certificate is not %s", tls_expecthash); | 870 | warnx("peer certificate is not %s", tls_expecthash); |
870 | else if (gotcert && tls_expectname && | 871 | else if (gotcert && tls_expectname && |
871 | (!tls_peer_cert_contains_name(tls_cctx, tls_expectname))) | 872 | (!tls_peer_cert_contains_name(tls_cctx, tls_expectname))) |