/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis *file,Youcanobtainoneathttp://mozilla.org/MPL/2.0/.
*/
std::vector<ByteString> extensions; if (endEntityOrCA == EndEntityOrCA::MustBeCA) {
ByteString basicConstraints =
CreateEncodedBasicConstraints(true, nullptr, Critical::Yes);
EXPECT_FALSE(ENCODING_FAILED(basicConstraints));
extensions.push_back(basicConstraints);
} if (subjectAlternativeNameExtension) {
extensions.push_back(*subjectAlternativeNameExtension);
} if (extendedKeyUsageExtension) {
extensions.push_back(*extendedKeyUsageExtension);
}
extensions.push_back(ByteString()); // marks the end of the list
// Test with "now" after the certificates have expired.
ASSERT_FALSE(VerifyCodeSigningCertificateChain(
&certificates[0], &certificateLengths[0], numCertificates,
secondsSinceEpoch + 10000000, &rootSHA256Digest[0], &hostname[0],
hostnameLength, &error));
ASSERT_EQ(error, SEC_ERROR_EXPIRED_ISSUER_CERTIFICATE);
// Test with a different root digest.
uint8_t wrongRootSHA256Digest[32] = {1};
ASSERT_FALSE(VerifyCodeSigningCertificateChain(
&certificates[0], &certificateLengths[0], numCertificates,
secondsSinceEpoch, &wrongRootSHA256Digest[0], &hostname[0],
hostnameLength, &error));
ASSERT_EQ(error, SEC_ERROR_UNKNOWN_ISSUER);
// Test with a different host name. const uint8_t wrongHostname[] = "example.org";
size_t wrongHostnameLength = strlen("example.org");
ASSERT_FALSE(VerifyCodeSigningCertificateChain(
&certificates[0], &certificateLengths[0], numCertificates,
secondsSinceEpoch, &rootSHA256Digest[0], &wrongHostname[0],
wrongHostnameLength, &error));
ASSERT_EQ(error, SSL_ERROR_BAD_CERT_DOMAIN);
// Test with a certificate with an extended key usage that doesn't include // code signing.
ByteString extendedKeyUsageExtension(
CreateEKUExtension(BytesToByteString(tlv_id_kp_clientAuth)));
ByteString endEntityWithEKU(
CreateCert("CA", "end-entity", EndEntityOrCA::MustBeEndEntity,
&subjectAltNameExtension, &extendedKeyUsageExtension)); const uint8_t* certificatesWithEKU[] = {endEntityWithEKU.data(), root.data()}; const uint16_t certificateLengthsWithEKU[] = {
static_cast<uint16_t>(endEntityWithEKU.length()),
static_cast<uint16_t>(root.length())};
ASSERT_FALSE(VerifyCodeSigningCertificateChain(
&certificatesWithEKU[0], &certificateLengthsWithEKU[0], numCertificates,
secondsSinceEpoch, &rootSHA256Digest[0], &hostname[0], hostnameLength,
&error));
ASSERT_EQ(error, SEC_ERROR_INADEQUATE_CERT_TYPE);
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.17 Sekunden
(vorverarbeitet am 2026-08-26)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.