diff options
author | Jack Lloyd <[email protected]> | 2017-11-14 12:33:03 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2017-11-14 16:19:45 -0500 |
commit | cd7866e3ec00beff057228cf3fb87b72df02f88f (patch) | |
tree | f7607b9d7b74c0d0138bd2e542e697e95a08cfb1 /src | |
parent | dafbe9848eb4386207bf5a7a6fdb86e34d720edf (diff) |
Add a test for GH #1252
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/x509/x509_dn.cpp | 8 | ||||
-rw-r--r-- | src/tests/data/misc_certs/opcuactt_ca.der | bin | 0 -> 1072 bytes | |||
-rw-r--r-- | src/tests/data/misc_certs/opcuactt_ca.pem | 28 | ||||
-rw-r--r-- | src/tests/unit_x509.cpp | 26 |
4 files changed, 61 insertions, 1 deletions
diff --git a/src/lib/x509/x509_dn.cpp b/src/lib/x509/x509_dn.cpp index ce1300e53..e705fe74d 100644 --- a/src/lib/x509/x509_dn.cpp +++ b/src/lib/x509/x509_dn.cpp @@ -79,7 +79,13 @@ std::multimap<std::string, std::string> X509_DN::contents() const { std::multimap<std::string, std::string> retval; for(auto i = m_dn_info.begin(); i != m_dn_info.end(); ++i) - multimap_insert(retval, OIDS::lookup(i->first), i->second.value()); + { + std::string str_value = OIDS::oid2str(i->first); + + if(str_value.empty()) + str_value = i->first.as_string(); + multimap_insert(retval, str_value, i->second.value()); + } return retval; } diff --git a/src/tests/data/misc_certs/opcuactt_ca.der b/src/tests/data/misc_certs/opcuactt_ca.der Binary files differnew file mode 100644 index 000000000..35e8e5cb0 --- /dev/null +++ b/src/tests/data/misc_certs/opcuactt_ca.der diff --git a/src/tests/data/misc_certs/opcuactt_ca.pem b/src/tests/data/misc_certs/opcuactt_ca.pem new file mode 100644 index 000000000..1987a0a07 --- /dev/null +++ b/src/tests/data/misc_certs/opcuactt_ca.pem @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQD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sJ9Pz/TJAeor4jRwzjBjh7bhbWM/B +ByHexUKsBUJe5rdOsF8qiyuY3OPVMEXz05iazaVF4qMtRpUSBoLljmRDY9Z5uh0d +SiOQOrUU8gXRXSTfbeHsKogU5Hg0nRAesiwom54K55HtjewqC3uc8A0c3wKBgQDC +XNNiFRKIN7o/CAvQFQAKb+YXUCLyM8H6nnSzFHph9LT8n4CUAhdVdCwTrp196eLE +P+mUswCBOnzYMpesgniEWtQE6cADn7FHVuctUr8t641irs1oaWYM4xkP68JOLCVT +iUpe9lcxxl1DyCuk25ImwHelkIKN9cYl/MJDotASKQKBgFMX48y7qyqYTZUnXHza +g8yVwpU3DaynPNd7IHwC2/Nj1jZW79Tg8YHzKxujvHSByyqt7UOY8oMTdywzqAh5 +JH3Z9JfPKFTp18cNk8Z0vhPnNV5lQPPXKaWsW7YW62AuDYTX/CwL9+Z+sCIQ/WBz +MMcuPWIKk0t5acScslBtLdk3 +-----END PRIVATE KEY----- diff --git a/src/tests/unit_x509.cpp b/src/tests/unit_x509.cpp index aab0b83d5..da60348c8 100644 --- a/src/tests/unit_x509.cpp +++ b/src/tests/unit_x509.cpp @@ -11,6 +11,7 @@ #include <botan/calendar.h> #include <botan/pkcs10.h> + #include <botan/pkcs8.h> #include <botan/x509self.h> #include <botan/x509path.h> #include <botan/x509_ca.h> @@ -358,6 +359,30 @@ Test::Result test_x509_dates() return result; } +Test::Result test_crl_dn_name() + { + Test::Result result("CRL DN name"); + + // See GH #1252 + + const Botan::OID dc_oid("0.9.2342.19200300.100.1.25"); + + Botan::X509_Certificate cert(Test::data_file("misc_certs/opcuactt_ca.der")); + + Botan::DataSource_Stream key_input(Test::data_file("misc_certs/opcuactt_ca.pem")); + std::unique_ptr<Botan::Private_Key> key = Botan::PKCS8::load_key(key_input); + Botan::X509_CA ca(cert, *key, "SHA-256", Test::rng()); + + Botan::X509_CRL crl = ca.new_crl(Test::rng()); + + result.confirm("matches issuer cert", crl.issuer_dn() == cert.subject_dn()); + + result.confirm("contains DC component", + crl.issuer_dn().get_attributes().count(dc_oid) == 1); + + return result; + } + Test::Result test_x509_utf8() { Test::Result result("X509 with UTF-8 encoded fields"); @@ -1219,6 +1244,7 @@ class X509_Cert_Unit_Tests final : public Test results.push_back(test_hashes("ECDSA")); results.push_back(test_x509_utf8()); results.push_back(test_x509_bmpstring()); + results.push_back(test_crl_dn_name()); return results; } |