Skip to content

Commit

Permalink
bug 1441223 - add a new (overridable) error code to describe extra po…
Browse files Browse the repository at this point in the history
…licy constraint failures r=jcj

Certificate verification failures that result from additional policy constraint
failures now use the error code
"MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED" (also known as
"Result::ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED", depending on the context).

MozReview-Commit-ID: 9rE7gRBapRF
  • Loading branch information
mozkeeler committed Feb 27, 2018
1 parent 5f938be commit 0c7cb26
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions security/certverifier/NSSCertDBTrustDomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,7 @@ NSSCertDBTrustDomain::IsChainValid(const DERArray& certArray, Time time,
// This chain is supposed to be complete, so this is an error. There
// are no intermediates, so return before searching just as if the
// search failed.
return Result::ERROR_POLICY_VALIDATION_FAILED;
return Result::ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED;
}

bool foundRequiredIntermediate = false;
Expand All @@ -878,7 +878,7 @@ NSSCertDBTrustDomain::IsChainValid(const DERArray& certArray, Time time,
}

if (!foundRequiredIntermediate) {
return Result::ERROR_POLICY_VALIDATION_FAILED;
return Result::ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED;
}
}

Expand Down Expand Up @@ -913,7 +913,7 @@ NSSCertDBTrustDomain::IsChainValid(const DERArray& certArray, Time time,
return Result::FATAL_ERROR_LIBRARY_FAILURE;
}
if (isDistrusted) {
return Result::ERROR_UNKNOWN_ISSUER;
return Result::ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,3 +327,4 @@ MOZILLA_PKIX_ERROR_VALIDITY_TOO_LONG=The server presented a certificate that is
MOZILLA_PKIX_ERROR_REQUIRED_TLS_FEATURE_MISSING=A required TLS feature is missing.
MOZILLA_PKIX_ERROR_INVALID_INTEGER_ENCODING=The server presented a certificate that contains an invalid encoding of an integer. Common causes include negative serial numbers, negative RSA moduli, and encodings that are longer than necessary.
MOZILLA_PKIX_ERROR_EMPTY_ISSUER_NAME=The server presented a certificate with an empty issuer distinguished name.
MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED=An additional policy constraint failed when validating this certificate.
1 change: 1 addition & 0 deletions security/manager/ssl/NSSErrorsService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ ErrorIsOverridable(PRErrorCode code)
switch (code)
{
// Overridable errors.
case mozilla::pkix::MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED:
case mozilla::pkix::MOZILLA_PKIX_ERROR_CA_CERT_USED_AS_END_ENTITY:
case mozilla::pkix::MOZILLA_PKIX_ERROR_EMPTY_ISSUER_NAME:
case mozilla::pkix::MOZILLA_PKIX_ERROR_INADEQUATE_KEY_SIZE:
Expand Down
3 changes: 3 additions & 0 deletions security/manager/ssl/SSLServerCertVerification.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ MapOverridableErrorToProbeValue(PRErrorCode errorCode)
return 15;
case SEC_ERROR_INVALID_TIME: return 16;
case mozilla::pkix::MOZILLA_PKIX_ERROR_EMPTY_ISSUER_NAME: return 17;
case mozilla::pkix::MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED:
return 18;
}
NS_WARNING("Unknown certificate error code. Does MapOverridableErrorToProbeValue "
"handle everything in DetermineCertOverrideErrors?");
Expand Down Expand Up @@ -359,6 +361,7 @@ DetermineCertOverrideErrors(const UniqueCERTCertificate& cert,
case SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE:
case SEC_ERROR_UNKNOWN_ISSUER:
case SEC_ERROR_CA_CERT_INVALID:
case mozilla::pkix::MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED:
case mozilla::pkix::MOZILLA_PKIX_ERROR_CA_CERT_USED_AS_END_ENTITY:
case mozilla::pkix::MOZILLA_PKIX_ERROR_INADEQUATE_KEY_SIZE:
case mozilla::pkix::MOZILLA_PKIX_ERROR_V1_CERT_USED_AS_CA:
Expand Down
1 change: 1 addition & 0 deletions security/manager/ssl/tests/unit/head_psm.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const MOZILLA_PKIX_ERROR_NOT_YET_VALID_ISSUER_CERTIFICATE = MOZILLA_PKIX_ERROR_B
const MOZILLA_PKIX_ERROR_OCSP_RESPONSE_FOR_CERT_MISSING = MOZILLA_PKIX_ERROR_BASE + 8;
const MOZILLA_PKIX_ERROR_REQUIRED_TLS_FEATURE_MISSING = MOZILLA_PKIX_ERROR_BASE + 10;
const MOZILLA_PKIX_ERROR_EMPTY_ISSUER_NAME = MOZILLA_PKIX_ERROR_BASE + 12;
const MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED = MOZILLA_PKIX_ERROR_BASE + 13;

// Supported Certificate Usages
const certificateUsageSSLClient = 0x0001;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ add_connection_test("symantec-not-whitelisted-after-cutoff.example.com",

// Not whitelisted certs before the cutoff are to be distrusted
add_connection_test("symantec-not-whitelisted-before-cutoff.example.com",
SEC_ERROR_UNKNOWN_ISSUER, null, null);
MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED,
null, null);

// Disable the distrust, should be back to the console warning
add_test(function() {
Expand Down
2 changes: 2 additions & 0 deletions security/pkix/include/pkix/Result.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ static const unsigned int FATAL_ERROR_FLAG = 0x800;
MOZILLA_PKIX_ERROR_INVALID_INTEGER_ENCODING) \
MOZILLA_PKIX_MAP(ERROR_EMPTY_ISSUER_NAME, 53, \
MOZILLA_PKIX_ERROR_EMPTY_ISSUER_NAME) \
MOZILLA_PKIX_MAP(ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED, 54, \
MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED) \
MOZILLA_PKIX_MAP(FATAL_ERROR_INVALID_ARGS, FATAL_ERROR_FLAG | 1, \
SEC_ERROR_INVALID_ARGS) \
MOZILLA_PKIX_MAP(FATAL_ERROR_INVALID_STATE, FATAL_ERROR_FLAG | 2, \
Expand Down
1 change: 1 addition & 0 deletions security/pkix/include/pkix/pkixnss.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ enum ErrorCode
MOZILLA_PKIX_ERROR_REQUIRED_TLS_FEATURE_MISSING = ERROR_BASE + 10,
MOZILLA_PKIX_ERROR_INVALID_INTEGER_ENCODING = ERROR_BASE + 11,
MOZILLA_PKIX_ERROR_EMPTY_ISSUER_NAME = ERROR_BASE + 12,
MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED = ERROR_BASE + 13,
END_OF_LIST
};

Expand Down
3 changes: 3 additions & 0 deletions security/pkix/lib/pkixnss.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,9 @@ RegisterErrorTable()
{ "MOZILLA_PKIX_ERROR_EMPTY_ISSUER_NAME",
"The server presented a certificate with an empty issuer distinguished "
"name." },
{ "MOZILLA_PKIX_ERROR_ADDITIONAL_POLICY_CONSTRAINT_FAILED",
"An additional policy constraint failed when validating this "
"certificate." },
};
// Note that these error strings are not localizable.
// When these strings change, update the localization information too.
Expand Down

0 comments on commit 0c7cb26

Please sign in to comment.