diff options
author | beck <> | 2021-10-26 09:09:53 +0000 |
---|---|---|
committer | beck <> | 2021-10-26 09:09:53 +0000 |
commit | fa1f14e289e900bc95217fa67f0aba88712ea0ae (patch) | |
tree | 1ffab474bea99fad4d76253c4288a7854a26df0c /src/lib/libcrypto/x509/x509_constraints.c | |
parent | 9ecdb7b0d743875dc4c14dc28389438c08c73c7d (diff) | |
download | openbsd-fa1f14e289e900bc95217fa67f0aba88712ea0ae.tar.gz openbsd-fa1f14e289e900bc95217fa67f0aba88712ea0ae.tar.bz2 openbsd-fa1f14e289e900bc95217fa67f0aba88712ea0ae.zip |
Validate Subject Alternate Names when they are being added to certificates.
With this change we will reject adding SAN DNS, EMAIL, and IP addresses
that are malformed at certificate creation time.
ok jsing@ tb@
Diffstat (limited to 'src/lib/libcrypto/x509/x509_constraints.c')
-rw-r--r-- | src/lib/libcrypto/x509/x509_constraints.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/libcrypto/x509/x509_constraints.c b/src/lib/libcrypto/x509/x509_constraints.c index db33bf1aa4..f5e1050bb1 100644 --- a/src/lib/libcrypto/x509/x509_constraints.c +++ b/src/lib/libcrypto/x509/x509_constraints.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_constraints.c,v 1.17 2021/09/23 15:49:48 jsing Exp $ */ | 1 | /* $OpenBSD: x509_constraints.c,v 1.18 2021/10/26 09:09:53 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> | 3 | * Copyright (c) 2020 Bob Beck <beck@openbsd.org> |
4 | * | 4 | * |
@@ -424,9 +424,14 @@ x509_constraints_parse_mailbox(uint8_t *candidate, size_t len, | |||
424 | strlen(candidate_domain))) | 424 | strlen(candidate_domain))) |
425 | goto bad; | 425 | goto bad; |
426 | 426 | ||
427 | name->local = candidate_local; | 427 | if (name != NULL) { |
428 | name->name = candidate_domain; | 428 | name->local = candidate_local; |
429 | name->type = GEN_EMAIL; | 429 | name->name = candidate_domain; |
430 | name->type = GEN_EMAIL; | ||
431 | } else { | ||
432 | free(candidate_local); | ||
433 | free(candidate_domain); | ||
434 | } | ||
430 | return 1; | 435 | return 1; |
431 | bad: | 436 | bad: |
432 | free(candidate_local); | 437 | free(candidate_local); |
@@ -511,7 +516,8 @@ x509_constraints_uri_host(uint8_t *uri, size_t len, char **hostpart) | |||
511 | host = authority; | 516 | host = authority; |
512 | if (!x509_constraints_valid_host(host, hostlen)) | 517 | if (!x509_constraints_valid_host(host, hostlen)) |
513 | return 0; | 518 | return 0; |
514 | *hostpart = strndup(host, hostlen); | 519 | if (hostpart != NULL) |
520 | *hostpart = strndup(host, hostlen); | ||
515 | return 1; | 521 | return 1; |
516 | } | 522 | } |
517 | 523 | ||