@ -10,7 +10,6 @@
# include "common_cert_errors.h"
# include "test_helpers.h"
# include <gtest/gtest.h>
# include <gtest/gtest.h>
namespace bssl {
namespace {
@ -49,12 +48,14 @@ namespace {
std : : string * result_der ) {
: : testing : : AssertionResult load_result =
LoadTestSubjectAltNameData ( basename , result_der ) ;
if ( ! load_result )
if ( ! load_result ) {
return load_result ;
}
CertErrors errors ;
* result = GeneralNames : : Create ( der : : Input ( result_der ) , & errors ) ;
if ( ! * result )
* result = GeneralNames : : Create ( der : : Input ( * result_der ) , & errors ) ;
if ( ! * result ) {
return : : testing : : AssertionFailure ( ) < < " Create failed " ;
}
return : : testing : : AssertionSuccess ( ) ;
}
@ -92,7 +93,7 @@ TEST_P(ParseNameConstraints, DNSNames) {
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_TRUE ( name_constraints - > IsPermittedDNSName ( " permitted.example.com " ) ) ;
@ -181,7 +182,7 @@ TEST_P(ParseNameConstraints,
ASSERT_TRUE ( LoadTestNameConstraint ( " dnsname2.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// Matches permitted exactly.
@ -212,7 +213,7 @@ TEST_P(ParseNameConstraints, DNSNamesPermittedWithLeadingDot) {
LoadTestNameConstraint ( " dnsname-permitted_with_leading_dot.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// A permitted dNSName constraint of ".bar.com" should only match subdomains
@ -230,7 +231,7 @@ TEST_P(ParseNameConstraints, DNSNamesExcludedWithLeadingDot) {
LoadTestNameConstraint ( " dnsname-excluded_with_leading_dot.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// An excluded dNSName constraint of ".bar.com" should only match subdomains
@ -247,7 +248,7 @@ TEST_P(ParseNameConstraints, DNSNamesPermittedTwoDot) {
ASSERT_TRUE ( LoadTestNameConstraint ( " dnsname-permitted_two_dot.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// A dNSName constraint of ".." isn't meaningful. Shouldn't match anything.
@ -263,7 +264,7 @@ TEST_P(ParseNameConstraints, DNSNamesExcludeOnly) {
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// Only "excluded.permitted.example.com" is excluded, and since permitted is
@ -283,7 +284,7 @@ TEST_P(ParseNameConstraints, DNSNamesExcludeAll) {
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// "permitted.example.com" is in the permitted section, but since "" is
@ -301,7 +302,7 @@ TEST_P(ParseNameConstraints, DNSNamesExcludeDot) {
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// "." is excluded, which should match nothing.
@ -320,7 +321,7 @@ TEST_P(ParseNameConstraints, DNSNamesFailOnInvalidIA5String) {
a . replace ( replace_location , 1 , 1 , - 1 ) ;
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
}
TEST_P ( ParseNameConstraints , DirectoryNames ) {
@ -347,49 +348,49 @@ TEST_P(ParseNameConstraints, DirectoryNames) {
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// Not in any permitted subtree.
EXPECT_FALSE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_ca ) ) ) ;
SequenceValueFromString ( name_ca ) ) ) ;
// Within the permitted C=US subtree.
EXPECT_TRUE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_us ) ) ) ;
SequenceValueFromString ( name_us ) ) ) ;
// Within the permitted C=US subtree.
EXPECT_TRUE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_us_az ) ) ) ;
SequenceValueFromString ( name_us_az ) ) ) ;
// Within the permitted C=US subtree, however the excluded C=US,ST=California
// subtree takes priority.
EXPECT_FALSE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_us_ca ) ) ) ;
SequenceValueFromString ( name_us_ca ) ) ) ;
// Within the permitted C=US subtree as well as the permitted
// C=US,ST=California,L=Mountain View subtree, however the excluded
// C=US,ST=California subtree still takes priority.
EXPECT_FALSE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_us_ca_mountain_view ) ) ) ;
SequenceValueFromString ( name_us_ca_mountain_view ) ) ) ;
// Not in any permitted subtree, and also inside the extraneous excluded C=DE
// subtree.
EXPECT_FALSE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_de ) ) ) ;
SequenceValueFromString ( name_de ) ) ) ;
// Not in any permitted subtree.
EXPECT_FALSE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_jp ) ) ) ;
SequenceValueFromString ( name_jp ) ) ) ;
// Within the permitted C=JP,ST=Tokyo subtree.
EXPECT_TRUE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_jp_tokyo ) ) ) ;
SequenceValueFromString ( name_jp_tokyo ) ) ) ;
EXPECT_EQ ( GENERAL_NAME_DIRECTORY_NAME ,
name_constraints - > constrained_name_types ( ) ) ;
// Within the permitted C=US subtree.
EXPECT_TRUE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name_us ) ,
SequenceValueFromString ( name_us ) ,
nullptr /* subject_alt_names */ ) ) ;
// Within the permitted C=US subtree, however the excluded C=US,ST=California
// subtree takes priority.
EXPECT_FALSE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name_us_ca ) ,
SequenceValueFromString ( name_us_ca ) ,
nullptr /* subject_alt_names */ ) ) ;
std : : string san_der ;
@ -417,7 +418,7 @@ TEST_P(ParseNameConstraints, DirectoryNamesExcludeOnly) {
LoadTestNameConstraint ( " directoryname-excluded.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
std : : string name_empty ;
@ -433,13 +434,13 @@ TEST_P(ParseNameConstraints, DirectoryNamesExcludeOnly) {
// Only "C=US,ST=California" is excluded, and since permitted is empty,
// any directoryName outside that is allowed.
EXPECT_TRUE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_empty ) ) ) ;
SequenceValueFromString ( name_empty ) ) ) ;
EXPECT_TRUE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_us ) ) ) ;
SequenceValueFromString ( name_us ) ) ) ;
EXPECT_FALSE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_us_ca ) ) ) ;
SequenceValueFromString ( name_us_ca ) ) ) ;
EXPECT_FALSE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_us_ca_mountain_view ) ) ) ;
SequenceValueFromString ( name_us_ca_mountain_view ) ) ) ;
}
TEST_P ( ParseNameConstraints , DirectoryNamesExcludeAll ) {
@ -448,7 +449,7 @@ TEST_P(ParseNameConstraints, DirectoryNamesExcludeAll) {
LoadTestNameConstraint ( " directoryname-excludeall.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
std : : string name_empty ;
@ -466,22 +467,22 @@ TEST_P(ParseNameConstraints, DirectoryNamesExcludeAll) {
// "C=US" is in the permitted section, but since an empty
// directoryName is excluded, nothing is permitted.
EXPECT_FALSE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_empty ) ) ) ;
SequenceValueFromString ( name_empty ) ) ) ;
EXPECT_FALSE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_us ) ) ) ;
SequenceValueFromString ( name_us ) ) ) ;
EXPECT_FALSE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_us_ca ) ) ) ;
SequenceValueFromString ( name_us_ca ) ) ) ;
EXPECT_FALSE ( name_constraints - > IsPermittedDirectoryName (
SequenceValueFromString ( & name_jp ) ) ) ;
SequenceValueFromString ( name_jp ) ) ) ;
}
TEST_P ( ParseNameConstraints , IPAdresses ) {
TEST_P ( ParseNameConstraints , IPAdd resses ) {
std : : string a ;
ASSERT_TRUE ( LoadTestNameConstraint ( " ipaddress.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// IPv4 tests:
@ -597,13 +598,13 @@ TEST_P(ParseNameConstraints, IPAdresses) {
IsPermittedCert ( name_constraints . get ( ) , der : : Input ( ) , san . get ( ) ) ) ;
}
TEST_P ( ParseNameConstraints , IPAdressesExcludeOnly ) {
TEST_P ( ParseNameConstraints , IPAdd ressesExcludeOnly ) {
std : : string a ;
ASSERT_TRUE ( LoadTestNameConstraint ( " ipaddress-excluded.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// Only 192.168.5.0/255.255.255.0 is excluded, and since permitted is empty,
@ -614,13 +615,13 @@ TEST_P(ParseNameConstraints, IPAdressesExcludeOnly) {
fillins : : IPAddress ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 13 , 0 , 0 , 0 , 1 ) ) ) ;
}
TEST_P ( ParseNameConstraints , IPAdressesExcludeAll ) {
TEST_P ( ParseNameConstraints , IPAdd ressesExcludeAll ) {
std : : string a ;
ASSERT_TRUE ( LoadTestNameConstraint ( " ipaddress-excludeall.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// 192.168.0.0/255.255.0.0 and
@ -634,13 +635,13 @@ TEST_P(ParseNameConstraints, IPAdressesExcludeAll) {
fillins : : IPAddress ( 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 13 , 0 , 0 , 0 , 1 ) ) ) ;
}
TEST_P ( ParseNameConstraints , IPAdressesNetmaskPermitSingleHost ) {
TEST_P ( ParseNameConstraints , IPAdd ressesNetmaskPermitSingleHost ) {
std : : string a ;
ASSERT_TRUE ( LoadTestNameConstraint ( " ipaddress-permit_singlehost.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_FALSE ( name_constraints - > IsPermittedIP ( fillins : : IPAddress : : IPv4AllZeros ( ) ) ) ;
@ -651,13 +652,13 @@ TEST_P(ParseNameConstraints, IPAdressesNetmaskPermitSingleHost) {
EXPECT_FALSE ( name_constraints - > IsPermittedIP ( fillins : : IPAddress ( 255 , 255 , 255 , 255 ) ) ) ;
}
TEST_P ( ParseNameConstraints , IPAdressesNetmaskPermitPrefixLen31 ) {
TEST_P ( ParseNameConstraints , IPAdd ressesNetmaskPermitPrefixLen31 ) {
std : : string a ;
ASSERT_TRUE ( LoadTestNameConstraint ( " ipaddress-permit_prefix31.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_FALSE ( name_constraints - > IsPermittedIP ( fillins : : IPAddress : : IPv4AllZeros ( ) ) ) ;
@ -669,13 +670,13 @@ TEST_P(ParseNameConstraints, IPAdressesNetmaskPermitPrefixLen31) {
EXPECT_FALSE ( name_constraints - > IsPermittedIP ( fillins : : IPAddress ( 255 , 255 , 255 , 255 ) ) ) ;
}
TEST_P ( ParseNameConstraints , IPAdressesNetmaskPermitPrefixLen1 ) {
TEST_P ( ParseNameConstraints , IPAdd ressesNetmaskPermitPrefixLen1 ) {
std : : string a ;
ASSERT_TRUE ( LoadTestNameConstraint ( " ipaddress-permit_prefix1.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_FALSE ( name_constraints - > IsPermittedIP ( fillins : : IPAddress : : IPv4AllZeros ( ) ) ) ;
@ -686,13 +687,13 @@ TEST_P(ParseNameConstraints, IPAdressesNetmaskPermitPrefixLen1) {
name_constraints - > IsPermittedIP ( fillins : : IPAddress ( 0xFF , 0xFF , 0xFF , 0xFF ) ) ) ;
}
TEST_P ( ParseNameConstraints , IPAdressesNetmaskPermitAll ) {
TEST_P ( ParseNameConstraints , IPAdd ressesNetmaskPermitAll ) {
std : : string a ;
ASSERT_TRUE ( LoadTestNameConstraint ( " ipaddress-permit_all.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_TRUE ( name_constraints - > IsPermittedIP ( fillins : : IPAddress : : IPv4AllZeros ( ) ) ) ;
@ -700,32 +701,65 @@ TEST_P(ParseNameConstraints, IPAdressesNetmaskPermitAll) {
EXPECT_TRUE ( name_constraints - > IsPermittedIP ( fillins : : IPAddress ( 255 , 255 , 255 , 255 ) ) ) ;
}
TEST_P ( ParseNameConstraints , IPAdressesFailOnInvalidAddr ) {
TEST_P ( ParseNameConstraints , IPAdd ressesFailOnInvalidAddr ) {
std : : string a ;
ASSERT_TRUE ( LoadTestNameConstraint ( " ipaddress-invalid_addr.pem " , & a ) ) ;
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
}
TEST_P ( ParseNameConstraints , IPAdressesFailOnInvalidMaskNotContiguous ) {
TEST_P ( ParseNameConstraints , IPAdd ressesFailOnInvalidMaskNotContiguous ) {
std : : string a ;
ASSERT_TRUE ( LoadTestNameConstraint (
" ipaddress-invalid_mask_not_contiguous_1.pem " , & a ) ) ;
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( LoadTestNameConstraint (
" ipaddress-invalid_mask_not_contiguous_2.pem " , & a ) ) ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( LoadTestNameConstraint (
" ipaddress-invalid_mask_not_contiguous_3.pem " , & a ) ) ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( LoadTestNameConstraint (
" ipaddress-invalid_mask_not_contiguous_4.pem " , & a ) ) ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & a ) , is_critical ( ) , & errors ) ) ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
}
// Test that v4/v6 mapping is not applied when evaluating name constraints.
TEST_P ( ParseNameConstraints , IPAddressesMapped ) {
std : : string a ;
ASSERT_TRUE ( LoadTestNameConstraint ( " ipaddress-mapped_addrs.pem " , & a ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints (
NameConstraints : : Create ( der : : Input ( a ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
// 192.168.1.0/24 is a permitted subtree.
EXPECT_TRUE ( name_constraints - > IsPermittedIP ( fillins : : IPAddress ( 192 , 168 , 1 , 0 ) ) ) ;
// This does not cover ::ffff:192.168.1.0.
EXPECT_FALSE ( name_constraints - > IsPermittedIP (
fillins : : IPAddress ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 255 , 255 , 192 , 168 , 1 , 0 ) ) ) ;
// 192.168.1.1 is excluded.
EXPECT_FALSE ( name_constraints - > IsPermittedIP ( fillins : : IPAddress ( 192 , 168 , 1 , 1 ) ) ) ;
// ::ffff:192.168.1.2 is excluded, but that does not exclude 192.168.1.2.
EXPECT_TRUE ( name_constraints - > IsPermittedIP ( fillins : : IPAddress ( 192 , 168 , 1 , 2 ) ) ) ;
// ::ffff:192.168.2.0/120 is a permitted subtree.
EXPECT_TRUE ( name_constraints - > IsPermittedIP (
fillins : : IPAddress ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 255 , 255 , 192 , 168 , 2 , 0 ) ) ) ;
// This does not cover 192.168.2.0.
EXPECT_FALSE ( name_constraints - > IsPermittedIP ( fillins : : IPAddress ( 192 , 168 , 2 , 0 ) ) ) ;
// ::ffff:192.168.2.1 is excluded.
EXPECT_FALSE ( name_constraints - > IsPermittedIP (
fillins : : IPAddress ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 255 , 255 , 192 , 168 , 2 , 1 ) ) ) ;
// 192.168.2.2 is excluded, but that does not exclude ::ffff:192.168.2.2.
EXPECT_TRUE ( name_constraints - > IsPermittedIP (
fillins : : IPAddress ( 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 255 , 255 , 192 , 168 , 2 , 2 ) ) ) ;
}
TEST_P ( ParseNameConstraints , OtherNamesInPermitted ) {
@ -734,7 +768,7 @@ TEST_P(ParseNameConstraints, OtherNamesInPermitted) {
LoadTestNameConstraint ( " othername-permitted.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
if ( is_critical ( ) ) {
@ -757,7 +791,7 @@ TEST_P(ParseNameConstraints, OtherNamesInExcluded) {
LoadTestNameConstraint ( " othername-excluded.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
if ( is_critical ( ) ) {
@ -780,7 +814,7 @@ TEST_P(ParseNameConstraints, Rfc822NamesInPermitted) {
LoadTestNameConstraint ( " rfc822name-permitted.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -842,7 +876,7 @@ TEST_P(ParseNameConstraints, Rfc822NamesInExcluded) {
LoadTestNameConstraint ( " rfc822name-excluded.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -892,7 +926,7 @@ TEST_P(ParseNameConstraints, Rfc822NameHostnameInPermitted) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -951,7 +985,7 @@ TEST_P(ParseNameConstraints, Rfc822NameHostnameInExcluded) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -1000,7 +1034,7 @@ TEST_P(ParseNameConstraints, Rfc822NameHostnameWithAtInPermitted) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -1050,7 +1084,7 @@ TEST_P(ParseNameConstraints, Rfc822NameHostnameWithAtInExcluded) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -1100,7 +1134,7 @@ TEST_P(ParseNameConstraints, Rfc822NameSubdomainInPermitted) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -1138,7 +1172,7 @@ TEST_P(ParseNameConstraints, Rfc822NameSubdomainInExcluded) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -1177,7 +1211,7 @@ TEST_P(ParseNameConstraints, Rfc822NameEmptyPermitted) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -1202,7 +1236,7 @@ TEST_P(ParseNameConstraints, Rfc822NameEmptyExcluded) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -1227,7 +1261,7 @@ TEST_P(ParseNameConstraints, Rfc822NameIPv4Permitted) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -1257,7 +1291,7 @@ TEST_P(ParseNameConstraints, Rfc822NameIPv4Excluded) {
LoadTestNameConstraint ( " rfc822name-excluded-ipv4.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
EXPECT_EQ ( GENERAL_NAME_RFC822_NAME ,
@ -1288,7 +1322,7 @@ TEST_P(ParseNameConstraints, QuotedRfc822SanWithNoRfc822Constraints) {
LoadTestNameConstraint ( " othername-excluded.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
std : : string san_der ;
@ -1306,7 +1340,7 @@ TEST_P(ParseNameConstraints, QuotedRfc822SanMatchesQuotedPermitted) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
std : : string san_der ;
@ -1325,7 +1359,7 @@ TEST_P(ParseNameConstraints, UnquotedRfc822SanNotMatchingQuotedExcluded) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
std : : string san_der ;
@ -1345,7 +1379,7 @@ TEST_P(ParseNameConstraints, X400AddresssInPermitted) {
LoadTestNameConstraint ( " x400address-permitted.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
if ( is_critical ( ) ) {
@ -1368,7 +1402,7 @@ TEST_P(ParseNameConstraints, X400AddresssInExcluded) {
LoadTestNameConstraint ( " x400address-excluded.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
if ( is_critical ( ) ) {
@ -1391,7 +1425,7 @@ TEST_P(ParseNameConstraints, EdiPartyNamesInPermitted) {
LoadTestNameConstraint ( " edipartyname-permitted.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
if ( is_critical ( ) ) {
@ -1414,7 +1448,7 @@ TEST_P(ParseNameConstraints, EdiPartyNamesInExcluded) {
LoadTestNameConstraint ( " edipartyname-excluded.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
if ( is_critical ( ) ) {
@ -1436,7 +1470,7 @@ TEST_P(ParseNameConstraints, URIsInPermitted) {
ASSERT_TRUE ( LoadTestNameConstraint ( " uri-permitted.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
if ( is_critical ( ) ) {
@ -1458,7 +1492,7 @@ TEST_P(ParseNameConstraints, URIsInExcluded) {
ASSERT_TRUE ( LoadTestNameConstraint ( " uri-excluded.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
if ( is_critical ( ) ) {
@ -1481,7 +1515,7 @@ TEST_P(ParseNameConstraints, RegisteredIDsInPermitted) {
LoadTestNameConstraint ( " registeredid-permitted.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
if ( is_critical ( ) ) {
@ -1504,7 +1538,7 @@ TEST_P(ParseNameConstraints, RegisteredIDsInExcluded) {
LoadTestNameConstraint ( " registeredid-excluded.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
if ( is_critical ( ) ) {
@ -1530,7 +1564,7 @@ TEST_P(ParseNameConstraints,
// could be changed to allowed if there are buggy encoders out there that
// include it anyway.
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & constraints_der ) ,
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( constraints_der ) ,
is_critical ( ) , & errors ) ) ;
}
@ -1539,7 +1573,7 @@ TEST_P(ParseNameConstraints, FailsOnGeneralSubtreeWithMinimum) {
ASSERT_TRUE (
LoadTestNameConstraint ( " dnsname-with_min_1.pem " , & constraints_der ) ) ;
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & constraints_der ) ,
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( constraints_der ) ,
is_critical ( ) , & errors ) ) ;
}
@ -1549,7 +1583,7 @@ TEST_P(ParseNameConstraints,
ASSERT_TRUE ( LoadTestNameConstraint ( " dnsname-with_min_0_and_max.pem " ,
& constraints_der ) ) ;
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & constraints_der ) ,
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( constraints_der ) ,
is_critical ( ) , & errors ) ) ;
}
@ -1558,7 +1592,7 @@ TEST_P(ParseNameConstraints, FailsOnGeneralSubtreeWithMinimumAndMaximum) {
ASSERT_TRUE ( LoadTestNameConstraint ( " dnsname-with_min_1_and_max.pem " ,
& constraints_der ) ) ;
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & constraints_der ) ,
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( constraints_der ) ,
is_critical ( ) , & errors ) ) ;
}
@ -1566,14 +1600,14 @@ TEST_P(ParseNameConstraints, FailsOnGeneralSubtreeWithMaximum) {
std : : string constraints_der ;
ASSERT_TRUE ( LoadTestNameConstraint ( " dnsname-with_max.pem " , & constraints_der ) ) ;
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & constraints_der ) ,
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( constraints_der ) ,
is_critical ( ) , & errors ) ) ;
}
TEST_P ( ParseNameConstraints , FailsOnEmptyExtensionValue ) {
std : : string constraints_der = " " ;
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & constraints_der ) ,
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( constraints_der ) ,
is_critical ( ) , & errors ) ) ;
}
@ -1582,7 +1616,7 @@ TEST_P(ParseNameConstraints, FailsOnNoPermittedAndExcluded) {
ASSERT_TRUE (
LoadTestNameConstraint ( " invalid-no_subtrees.pem " , & constraints_der ) ) ;
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & constraints_der ) ,
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( constraints_der ) ,
is_critical ( ) , & errors ) ) ;
}
@ -1591,7 +1625,7 @@ TEST_P(ParseNameConstraints, FailsOnEmptyPermitted) {
ASSERT_TRUE ( LoadTestNameConstraint ( " invalid-empty_permitted_subtree.pem " ,
& constraints_der ) ) ;
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & constraints_der ) ,
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( constraints_der ) ,
is_critical ( ) , & errors ) ) ;
}
@ -1600,7 +1634,7 @@ TEST_P(ParseNameConstraints, FailsOnEmptyExcluded) {
ASSERT_TRUE ( LoadTestNameConstraint ( " invalid-empty_excluded_subtree.pem " ,
& constraints_der ) ) ;
CertErrors errors ;
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( & constraints_der ) ,
EXPECT_FALSE ( NameConstraints : : Create ( der : : Input ( constraints_der ) ,
is_critical ( ) , & errors ) ) ;
}
@ -1610,7 +1644,7 @@ TEST_P(ParseNameConstraints,
ASSERT_TRUE ( LoadTestNameConstraint ( " directoryname.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
std : : string name ;
@ -1618,14 +1652,14 @@ TEST_P(ParseNameConstraints,
// Name constraints don't contain rfc822Name, so emailAddress in subject is
// allowed regardless.
EXPECT_TRUE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name ) ,
SequenceValueFromString ( name ) ,
/*subject_alt_names=*/ nullptr ) ) ;
ASSERT_TRUE ( LoadTestName ( " name-us-arizona-email-invalidstring.pem " , & name ) ) ;
// Name constraints don't contain rfc822Name, so emailAddress in subject is
// allowed regardless.
EXPECT_TRUE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name ) ,
SequenceValueFromString ( name ) ,
/*subject_alt_names=*/ nullptr ) ) ;
}
@ -1635,7 +1669,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectEmailAddressIsOk) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
std : : string name ;
@ -1644,21 +1678,21 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectEmailAddressIsOk) {
// Name constraints contain rfc822Name, and the address matches the
// constraint (which is all addresses on the hostname.)
EXPECT_TRUE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name ) ,
SequenceValueFromString ( name ) ,
/*subject_alt_names=*/ nullptr ) ) ;
ASSERT_TRUE ( LoadTestName ( " name-us-arizona-email-invalidstring.pem " , & name ) ) ;
// The bytes of the name string match, but the string type is VISIBLESTRING
// which is not supported, so this should fail.
EXPECT_FALSE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name ) ,
SequenceValueFromString ( name ) ,
/*subject_alt_names=*/ nullptr ) ) ;
ASSERT_TRUE ( LoadTestName ( " name-us-arizona-email-multiple.pem " , & name ) ) ;
// Subject contains multiple rfc822Names, and they all match the constraint
// (which is all addresses on the hostname.)
EXPECT_TRUE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name ) ,
SequenceValueFromString ( name ) ,
/*subject_alt_names=*/ nullptr ) ) ;
}
@ -1668,7 +1702,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectEmailAddressIsNotOk) {
LoadTestNameConstraint ( " rfc822name-permitted.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
std : : string name ;
@ -1677,21 +1711,21 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectEmailAddressIsNotOk) {
// Name constraints contain rfc822Name, and the address does not match the
// constraint.
EXPECT_FALSE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name ) ,
SequenceValueFromString ( name ) ,
/*subject_alt_names=*/ nullptr ) ) ;
// Address is a case-insensitive match, but name constraints (permitted) are
// case-sensitive, so this fails.
ASSERT_TRUE ( LoadTestName ( " name-us-arizona-email-localpartcase.pem " , & name ) ) ;
EXPECT_FALSE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name ) ,
SequenceValueFromString ( name ) ,
/*subject_alt_names=*/ nullptr ) ) ;
ASSERT_TRUE ( LoadTestName ( " name-us-arizona-email-multiple.pem " , & name ) ) ;
// Subject contains multiple rfc822Names, and only the first one matches the
// constraint.
EXPECT_FALSE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name ) ,
SequenceValueFromString ( name ) ,
/*subject_alt_names=*/ nullptr ) ) ;
}
@ -1701,7 +1735,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectEmailAddressExcluded) {
LoadTestNameConstraint ( " rfc822name-excluded.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
std : : string name ;
@ -1710,21 +1744,21 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectEmailAddressExcluded) {
// Name constraints contain excluded rfc822Name, and the address does not
// match the constraint.
EXPECT_TRUE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name ) ,
SequenceValueFromString ( name ) ,
/*subject_alt_names=*/ nullptr ) ) ;
// Name constraints for excluded are done case-insensitive in the local part,
// so this is not allowed.
ASSERT_TRUE ( LoadTestName ( " name-us-arizona-email-localpartcase.pem " , & name ) ) ;
EXPECT_FALSE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name ) ,
SequenceValueFromString ( name ) ,
/*subject_alt_names=*/ nullptr ) ) ;
ASSERT_TRUE ( LoadTestName ( " name-us-arizona-email-multiple.pem " , & name ) ) ;
// Subject contains multiple rfc822Names, and one of them is excluded by the
// constraint.
EXPECT_FALSE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name ) ,
SequenceValueFromString ( name ) ,
/*subject_alt_names=*/ nullptr ) ) ;
}
@ -1737,7 +1771,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectDnsNames) {
& constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
std : : string name_us_az_foocom ;
@ -1746,7 +1780,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectDnsNames) {
// (The commonName hostname is not within permitted dNSName constraints, so
// this would not be permitted if hostnames in commonName were checked.)
EXPECT_TRUE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name_us_az_foocom ) ,
SequenceValueFromString ( name_us_az_foocom ) ,
nullptr /* subject_alt_names */ ) ) ;
std : : string name_us_az_permitted ;
@ -1756,7 +1790,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectDnsNames) {
// permitted dNSName constraints, so this should be permitted regardless if
// hostnames in commonName are checked or not.
EXPECT_TRUE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name_us_az_permitted ) ,
SequenceValueFromString ( name_us_az_permitted ) ,
nullptr /* subject_alt_names */ ) ) ;
std : : string name_us_ca_permitted ;
@ -1766,7 +1800,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectDnsNames) {
// this should not be allowed, regardless of checking the
// permitted.example.com in commonName.
EXPECT_FALSE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name_us_ca_permitted ) ,
SequenceValueFromString ( name_us_ca_permitted ) ,
nullptr /* subject_alt_names */ ) ) ;
}
@ -1779,7 +1813,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectIpAddresses) {
" directoryname_and_dnsname_and_ipaddress.pem " , & constraints_der ) ) ;
CertErrors errors ;
std : : unique_ptr < NameConstraints > name_constraints ( NameConstraints : : Create (
der : : Input ( & constraints_der ) , is_critical ( ) , & errors ) ) ;
der : : Input ( constraints_der ) , is_critical ( ) , & errors ) ) ;
ASSERT_TRUE ( name_constraints ) ;
std : : string name_us_az_1_1_1_1 ;
@ -1788,7 +1822,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectIpAddresses) {
// (The commonName IP address is not within permitted iPAddresses constraints,
// so this would not be permitted if IP addresses in commonName were checked.)
EXPECT_TRUE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name_us_az_1_1_1_1 ) ,
SequenceValueFromString ( name_us_az_1_1_1_1 ) ,
nullptr /* subject_alt_names */ ) ) ;
std : : string name_us_az_192_168_1_1 ;
@ -1798,7 +1832,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectIpAddresses) {
// permitted iPAddress constraints, so this should be permitted regardless if
// IP addresses in commonName are checked or not.
EXPECT_TRUE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name_us_az_192_168_1_1 ) ,
SequenceValueFromString ( name_us_az_192_168_1_1 ) ,
nullptr /* subject_alt_names */ ) ) ;
std : : string name_us_ca_192_168_1_1 ;
@ -1808,7 +1842,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectIpAddresses) {
// this should not be allowed, regardless of checking the
// IP address in commonName.
EXPECT_FALSE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name_us_ca_192_168_1_1 ) ,
SequenceValueFromString ( name_us_ca_192_168_1_1 ) ,
nullptr /* subject_alt_names */ ) ) ;
std : : string name_us_az_ipv6 ;
@ -1817,7 +1851,7 @@ TEST_P(ParseNameConstraints, IsPermittedCertSubjectIpAddresses) {
// (The commonName is an ipv6 address which wasn't supported in the past, but
// since commonName checking is ignored entirely, this is permitted.)
EXPECT_TRUE ( IsPermittedCert ( name_constraints . get ( ) ,
SequenceValueFromString ( & name_us_az_ipv6 ) ,
SequenceValueFromString ( name_us_az_ipv6 ) ,
nullptr /* subject_alt_names */ ) ) ;
}