summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2024-11-12 22:50:06 +0000
committertb <>2024-11-12 22:50:06 +0000
commitcf5b89baef0d059b3a6b4ecd4b49409265157b81 (patch)
tree4090f9fd0252fcc655b896c428e7d97f0418050b /src/lib
parentd2ed7b4e4d92926fea691e61cefc2508f2384bcf (diff)
downloadopenbsd-cf5b89baef0d059b3a6b4ecd4b49409265157b81.tar.gz
openbsd-cf5b89baef0d059b3a6b4ecd4b49409265157b81.tar.bz2
openbsd-cf5b89baef0d059b3a6b4ecd4b49409265157b81.zip
The subject of a certificate is not optional
A certificate must have a subject, so X509_get_subject_name() cannot return NULL on a correctly parsed certificate, even if the subject is empty (which is allowed). So if X509_get_subject_name() returns NULL, error instead of silently ignoring it in tls_check_common_name(). This is currently no issue. Where it matters, the match against the common name will fail later, so we fail closed anyway. ok jsing
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libtls/tls_verify.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/lib/libtls/tls_verify.c b/src/lib/libtls/tls_verify.c
index 78f6c249cc..6b2a4fb82a 100644
--- a/src/lib/libtls/tls_verify.c
+++ b/src/lib/libtls/tls_verify.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: tls_verify.c,v 1.30 2024/03/26 06:24:52 joshua Exp $ */ 1/* $OpenBSD: tls_verify.c,v 1.31 2024/11/12 22:50:06 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org> 3 * Copyright (c) 2014 Jeremie Courreges-Anglas <jca@openbsd.org>
4 * 4 *
@@ -226,7 +226,7 @@ tls_check_common_name(struct tls *ctx, X509 *cert, const char *name,
226 226
227 subject_name = X509_get_subject_name(cert); 227 subject_name = X509_get_subject_name(cert);
228 if (subject_name == NULL) 228 if (subject_name == NULL)
229 goto done; 229 goto err;
230 230
231 lastpos = X509_NAME_get_index_by_NID(subject_name, 231 lastpos = X509_NAME_get_index_by_NID(subject_name,
232 NID_commonName, lastpos); 232 NID_commonName, lastpos);