summaryrefslogtreecommitdiff
path: root/test/certificates_test.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-01-08 17:53:04 +0100
committerCarl Hetherington <cth@carlh.net>2024-01-09 11:44:40 +0100
commit75d6411bb1f04a1375b00f361a0c1358d6e8d7ab (patch)
tree8e5da1f94c975190d3bb16716cbfed0759145581 /test/certificates_test.cc
parentff6474302e1481d98d8cd10bee11eceb4df050f1 (diff)
Fix escaping of certificate dnQualifier (public key digests) on creation (DoM #2716).v1.8.93
Diffstat (limited to 'test/certificates_test.cc')
-rw-r--r--test/certificates_test.cc23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/certificates_test.cc b/test/certificates_test.cc
index 4795e45e..7ac06428 100644
--- a/test/certificates_test.cc
+++ b/test/certificates_test.cc
@@ -279,3 +279,26 @@ BOOST_AUTO_TEST_CASE (certificate_not_before_after)
BOOST_CHECK_EQUAL (not_after.month(), 6);
BOOST_CHECK_EQUAL (not_after.year(), 2025);
}
+
+
+/** Check for correct escaping of public key digests */
+BOOST_AUTO_TEST_CASE(certificate_public_key_digest)
+{
+ BOOST_CHECK_EQUAL(dcp::public_key_digest("test/data/private.key"), "MekIXGBkYdh28siMnnF\\/Zs2JeK8=");
+ BOOST_CHECK_EQUAL(dcp::public_key_digest("test/data/private2.key"), "dfjStQNFTdVpfzgmxQCb3x\\+y2SY=");
+}
+
+
+/** Create some certificates and check that the dnQualifier read from the header is always what is should be;
+ * previously it would not be if the digest contained \ or + (DoM #2716).
+ */
+BOOST_AUTO_TEST_CASE(certificate_dn_qualifiers)
+{
+ for (auto i = 0; i < 50; ++i) {
+ dcp::CertificateChain chain(boost::filesystem::path("openssl"), 10 * 365);
+ for (auto cert: chain.unordered()) {
+ BOOST_CHECK_EQUAL(dcp::escape_digest(cert.subject_dn_qualifier()), dcp::public_key_digest(cert.public_key()));
+ }
+ }
+}
+