diff options
author | inoguchi <> | 2021-09-05 01:55:54 +0000 |
---|---|---|
committer | inoguchi <> | 2021-09-05 01:55:54 +0000 |
commit | 83ebf782e22a8260f1b7351fad667dea16e564e0 (patch) | |
tree | 2bea90f7763639386d4bddf8a150702b05a996b0 | |
parent | 7134aa2bffb65c1e99f76a6de8c4e8376d134e93 (diff) | |
download | openbsd-83ebf782e22a8260f1b7351fad667dea16e564e0.tar.gz openbsd-83ebf782e22a8260f1b7351fad667dea16e564e0.tar.bz2 openbsd-83ebf782e22a8260f1b7351fad667dea16e564e0.zip |
Using serial number instead as subject if it is empty in openssl(1) ca
This allows multiple entries without a subject even if unique_subject == yes.
Referred to OpenSSL commit 5af88441 and arranged for our codebase.
ok tb@
-rw-r--r-- | src/usr.bin/openssl/ca.c | 31 | ||||
-rw-r--r-- | src/usr.bin/openssl/openssl.1 | 8 |
2 files changed, 36 insertions, 3 deletions
diff --git a/src/usr.bin/openssl/ca.c b/src/usr.bin/openssl/ca.c index 1d28532ed3..b24febd9f6 100644 --- a/src/usr.bin/openssl/ca.c +++ b/src/usr.bin/openssl/ca.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ca.c,v 1.47 2021/09/05 01:49:42 inoguchi Exp $ */ | 1 | /* $OpenBSD: ca.c,v 1.48 2021/09/05 01:55:54 inoguchi Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -2124,6 +2124,21 @@ do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst, | |||
2124 | BIO_printf(bio_err, "Memory allocation failure\n"); | 2124 | BIO_printf(bio_err, "Memory allocation failure\n"); |
2125 | goto err; | 2125 | goto err; |
2126 | } | 2126 | } |
2127 | |||
2128 | if (row[DB_name][0] == '\0') { | ||
2129 | /* | ||
2130 | * An empty subject! We'll use the serial number instead. If | ||
2131 | * unique_subject is in use then we don't want different | ||
2132 | * entries with empty subjects matching each other. | ||
2133 | */ | ||
2134 | free(row[DB_name]); | ||
2135 | row[DB_name] = strdup(row[DB_serial]); | ||
2136 | if (row[DB_name] == NULL) { | ||
2137 | BIO_printf(bio_err, "Memory allocation failure\n"); | ||
2138 | goto err; | ||
2139 | } | ||
2140 | } | ||
2141 | |||
2127 | if (db->attributes.unique_subject) { | 2142 | if (db->attributes.unique_subject) { |
2128 | OPENSSL_STRING *crow = row; | 2143 | OPENSSL_STRING *crow = row; |
2129 | 2144 | ||
@@ -2469,6 +2484,20 @@ do_revoke(X509 *x509, CA_DB *db, int type, char *value) | |||
2469 | else | 2484 | else |
2470 | row[DB_serial] = BN_bn2hex(bn); | 2485 | row[DB_serial] = BN_bn2hex(bn); |
2471 | BN_free(bn); | 2486 | BN_free(bn); |
2487 | |||
2488 | if (row[DB_name] != NULL && row[DB_name][0] == '\0') { | ||
2489 | /* | ||
2490 | * Entries with empty Subjects actually use the serial number | ||
2491 | * instead | ||
2492 | */ | ||
2493 | free(row[DB_name]); | ||
2494 | row[DB_name] = strdup(row[DB_serial]); | ||
2495 | if (row[DB_name] == NULL) { | ||
2496 | BIO_printf(bio_err, "Memory allocation failure\n"); | ||
2497 | goto err; | ||
2498 | } | ||
2499 | } | ||
2500 | |||
2472 | if ((row[DB_name] == NULL) || (row[DB_serial] == NULL)) { | 2501 | if ((row[DB_name] == NULL) || (row[DB_serial] == NULL)) { |
2473 | BIO_printf(bio_err, "Memory allocation failure\n"); | 2502 | BIO_printf(bio_err, "Memory allocation failure\n"); |
2474 | goto err; | 2503 | goto err; |
diff --git a/src/usr.bin/openssl/openssl.1 b/src/usr.bin/openssl/openssl.1 index 9d9f5ca580..e698c33a0a 100644 --- a/src/usr.bin/openssl/openssl.1 +++ b/src/usr.bin/openssl/openssl.1 | |||
@@ -1,4 +1,4 @@ | |||
1 | .\" $OpenBSD: openssl.1,v 1.130 2021/08/29 12:33:15 tb Exp $ | 1 | .\" $OpenBSD: openssl.1,v 1.131 2021/09/05 01:55:54 inoguchi Exp $ |
2 | .\" ==================================================================== | 2 | .\" ==================================================================== |
3 | .\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. | 3 | .\" Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. |
4 | .\" | 4 | .\" |
@@ -110,7 +110,7 @@ | |||
110 | .\" copied and put under another distribution licence | 110 | .\" copied and put under another distribution licence |
111 | .\" [including the GNU Public Licence.] | 111 | .\" [including the GNU Public Licence.] |
112 | .\" | 112 | .\" |
113 | .Dd $Mdocdate: August 29 2021 $ | 113 | .Dd $Mdocdate: September 5 2021 $ |
114 | .Dt OPENSSL 1 | 114 | .Dt OPENSSL 1 |
115 | .Os | 115 | .Os |
116 | .Sh NAME | 116 | .Sh NAME |
@@ -843,6 +843,10 @@ is given, | |||
843 | several valid certificate entries may have the exact same subject. | 843 | several valid certificate entries may have the exact same subject. |
844 | The default value is | 844 | The default value is |
845 | .Cm yes . | 845 | .Cm yes . |
846 | .Pp | ||
847 | Note that it is valid in some circumstances for certificates to be created | ||
848 | without any subject. In the case where there are multiple certificates without | ||
849 | subjects this does not count as a duplicate. | ||
846 | .It Cm x509_extensions | 850 | .It Cm x509_extensions |
847 | The same as | 851 | The same as |
848 | .Fl extensions . | 852 | .Fl extensions . |