-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce X509CheckFlags::UNDERSCORE_WILDCARDS
- Loading branch information
Showing
10 changed files
with
186 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
https://github.com/google/boringssl/compare/master...nox:boringssl:underscore-wildcards | ||
|
||
--- a/src/crypto/x509v3/v3_utl.c | ||
+++ b/src/crypto/x509v3/v3_utl.c | ||
@@ -790,7 +790,9 @@ static int wildcard_match(const unsigned char *prefix, size_t prefix_len, | ||
// Check that the part matched by the wildcard contains only | ||
// permitted characters and only matches a single label. | ||
for (p = wildcard_start; p != wildcard_end; ++p) { | ||
- if (!OPENSSL_isalnum(*p) && *p != '-') { | ||
+ if (!OPENSSL_isalnum(*p) && *p != '-' && | ||
+ !(*p == '_' && | ||
+ (flags & X509_CHECK_FLAG_UNDERSCORE_WILDCARDS))) { | ||
return 0; | ||
} | ||
} | ||
--- a/src/crypto/x509/x509_test.cc | ||
+++ b/src/crypto/x509/x509_test.cc | ||
@@ -4500,6 +4500,31 @@ TEST(X509Test, Names) { | ||
/*invalid_emails=*/{}, | ||
/*flags=*/0, | ||
}, | ||
+ | ||
+ // Underscores in DNS names are forbidden by default. | ||
+ { | ||
+ /*cert_subject=*/{}, | ||
+ /*cert_dns_names=*/{"*.example.com"}, | ||
+ /*cert_emails=*/{}, | ||
+ /*valid_dns_names=*/{}, | ||
+ /*invalid_dns_names=*/{"not_allowed.example.com"}, | ||
+ /*valid_emails=*/{}, | ||
+ /*invalid_emails=*/{}, | ||
+ /*flags=*/0, | ||
+ }, | ||
+ | ||
+ // Underscores in DNS names can be allowed with the right flag. | ||
+ { | ||
+ /*cert_subject=*/{}, | ||
+ /*cert_dns_names=*/{"*.example.com"}, | ||
+ /*cert_emails=*/{}, | ||
+ /*valid_dns_names=*/{"now_allowed.example.com"}, | ||
+ /*invalid_dns_names=*/{}, | ||
+ /*valid_emails=*/{}, | ||
+ /*invalid_emails=*/{}, | ||
+ /*flags=*/X509_CHECK_FLAG_UNDERSCORE_WILDCARDS, | ||
+ }, | ||
+ | ||
}; | ||
|
||
size_t i = 0; | ||
--- a/src/include/openssl/x509c3.h | ||
+++ b/src/include/openssl/x509v3.h | ||
@@ -4497,6 +4497,8 @@ OPENSSL_EXPORT int X509_PURPOSE_get_id(const X509_PURPOSE *); | ||
#define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0 | ||
// Skip the subject common name fallback if subjectAltNames is missing. | ||
#define X509_CHECK_FLAG_NEVER_CHECK_SUBJECT 0x20 | ||
+// Allow underscores in DNS wildcard matches. | ||
+#define X509_CHECK_FLAG_UNDERSCORE_WILDCARDS 0x40 | ||
|
||
OPENSSL_EXPORT int X509_check_host(X509 *x, const char *chk, size_t chklen, | ||
unsigned int flags, char **peername); | ||
-- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
notAfter=Aug 12 11:30:03 2026 GMT | ||
-----BEGIN CERTIFICATE----- | ||
MIIDKDCCAhACFGwwuilXOHjBjQ584FD9drp9Uh/LMA0GCSqGSIb3DQEBCwUAMEUx | ||
CzAJBgNVBAYTAkFVMRMwEQYDVQQIDApTb21lLVN0YXRlMSEwHwYDVQQKDBhJbnRl | ||
cm5ldCBXaWRnaXRzIFB0eSBMdGQwHhcNMjMxMjE4MTEzMDAzWhcNMjYwODEyMTEz | ||
MDAzWjBcMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8GA1UE | ||
BwwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRUwEwYDVQQDDAwqLmZvb2Jhci5j | ||
b20wggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCo9CWMRLMXo1CF/iOR | ||
h9B4NhtJF/8tR9PlG95sNvyWuQQ/8jfev+8zErplxfLkt0pJqcoiZG8g9NU0kU6o | ||
5T+/1QgZclCAoZaS0Jqxmoo2Yk/1Qsj16pnMBc10uSDk6V9aJSX1vKwONVNSwiHA | ||
1MhX+i7Wf7/K0niq+k7hOkhleFkWgZtUq41gXh1VfOugka7UktYnk9mrBbAMjmal | ||
oZNn2pMMAQxVg4ThiLm3zvuWqvXASWzUZc7IAd1GbN4AtDuhs252eqE9E4iTHk7F | ||
14wAS1JWqv666hReGHrmZJGx0xQTM9vPD1HN5t2U3KTfhO/mTlAUWVyg9tCtOzbo | ||
Kgs1AgMB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