diff options
author | Rene Meusel <[email protected]> | 2019-04-12 14:02:24 +0200 |
---|---|---|
committer | Rene Meusel <[email protected]> | 2019-04-12 14:02:24 +0200 |
commit | 4d67f288889e7b6afe25379585b69d1458f7f100 (patch) | |
tree | 67e7b8c25c3dee54f176f7ddce97d66404fe8c8d /src | |
parent | 42681382aa58aca0effb2838a97fa1c632def2a7 (diff) |
TESt: flatfile cert store uses internal test file
Diffstat (limited to 'src')
-rw-r--r-- | src/tests/data/x509/misc/certstor/valid_ca_bundle.pem | 79 | ||||
-rw-r--r-- | src/tests/test_certstor_flatfile.cpp | 23 |
2 files changed, 93 insertions, 9 deletions
diff --git a/src/tests/data/x509/misc/certstor/valid_ca_bundle.pem b/src/tests/data/x509/misc/certstor/valid_ca_bundle.pem new file mode 100644 index 000000000..d1024179c --- /dev/null +++ b/src/tests/data/x509/misc/certstor/valid_ca_bundle.pem @@ -0,0 +1,79 @@ + +> D-TRUST Root Class 3 CA 2 EV 2009 + +-----BEGIN CERTIFICATE----- +MIIEQzCCAyugAwIBAgIDCYP0MA0GCSqGSIb3DQEBCwUAMFAxCzAJBgNVBAYTAkRF +MRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNVBAMMIUQtVFJVU1QgUm9vdCBD +bGFzcyAzIENBIDIgRVYgMjAwOTAeFw0wOTExMDUwODUwNDZaFw0yOTExMDUwODUw +NDZaMFAxCzAJBgNVBAYTAkRFMRUwEwYDVQQKDAxELVRydXN0IEdtYkgxKjAoBgNV +BAMMIUQtVFJVU1QgUm9vdCBDbGFzcyAzIENBIDIgRVYgMjAwOTCCASIwDQYJKoZI +hvcNAQEBBQADggEPADCCAQoCggEBAJnxhDRwui+3MKCOvXwEz75ivJn9gpfSegpn +ljgJ9hBOlSJzmY3aFS3nBfwZcyK3jpgAvDw9rKFs+9Z5JUut8Mxk2og+KbgPCdM0 +3TP1YtHhzRnp7hhPTFiu4h7WDFsVWtg6uMQYZB7jM7K1iXdODL/ZlGsTl28So/6Z +qQT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QsEjgfbKbYK7p2CNTUQ +-----END CERTIFICATE----- + +> VeriSign Class 3 Public Primary Certification Authority - G3 +> Note: this is a v1 style X.509 certificate + +-----BEGIN CERTIFICATE----- +MIIEGjCCAwICEQCbfgZJoz5iudXukEhxKe9XMA0GCSqGSIb3DQEBBQUAMIHKMQsw +CQYDVQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZl +cmlTaWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWdu +LCBJbmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlT +aWduIENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3Jp +dHkgLSBHMzAeFw05OTEwMDEwMDAwMDBaFw0zNjA3MTYyMzU5NTlaMIHKMQswCQYD +VQQGEwJVUzEXMBUGA1UEChMOVmVyaVNpZ24sIEluYy4xHzAdBgNVBAsTFlZlcmlT +aWduIFRydXN0IE5ldHdvcmsxOjA4BgNVBAsTMShjKSAxOTk5IFZlcmlTaWduLCBJ +bmMuIC0gRm9yIGF1dGhvcml6ZWQgdXNlIG9ubHkxRTBDBgNVBAMTPFZlcmlTaWdu +IENsYXNzIDMgUHVibGljIFByaW1hcnkgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkg +LSBHMzCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMu6nFL8eB8aHm8b +N3O9+MlrlBIwT/A2R/XQkQr1F8ilYcEWQE37imGQ5XYgwREGfassbqb1EUGO+i2t +KmFZpGcmTNDovFJbcCAEWNF6yaRpvIMXZK0Fi7zQWM6NjPXr8EJJC52XJ2cybuGu +kxUccLwgTS8Y3pKI6GyFVxEa6X7jJhFUokWWVYPKMIno3Nij7SqAP395ZVc+FSBm +CC+Vk7+qRy+oRpfwEuL+wgorUeZ25rdGt+INpsyow0xZVYnm6FNcHOqd8GIWC6fJ +Xwzw3sJ2zq/3avL6QaaiMxTJ5Xpj055iN9WFZZ4O5lMkdBteHRJTW8cs54NJOxWu +imi5V5cCAwEAATANBgkqhkiG9w0BAQUFAAOCAQEAERSWwauSCPc/L8my/uRan2Te +2yFPhpk0djZX3dAVL8WtfxUfN2JzPtTnX84XA9s1+ivbrmAJXx5fj267Cz3qWhMe +DGBvtcC1IyIuBwvLqXTLR7sdwdela8wv0kL9Sd2nic9TutoAWii/gt/4uhMdUIaC +/Y4wjylGsB49Ndo4YhYYSq3mtlFs3q9i6wHQHiT+eo8SGhJouPtmmRQURVyu565p +F4ErWjfJXir0xuKhXFSbplQAz/DxwceYMBo7Nhbbo27q/a2ywtrvAkcTisDxszGt +TxzhT5yvDwyd93gN2PQ1VoDat20Xj50egWTh/sVFuq1ruQp6Tk9LhO5L8X3dEQ== +-----END CERTIFICATE----- diff --git a/src/tests/test_certstor_flatfile.cpp b/src/tests/test_certstor_flatfile.cpp index 792a5b79a..472d1f2be 100644 --- a/src/tests/test_certstor_flatfile.cpp +++ b/src/tests/test_certstor_flatfile.cpp @@ -7,7 +7,7 @@ #include "tests.h" -#if defined(BOTAN_HAS_CERTSTOR_FLATFILE) && defined(BOTAN_SYSTEM_CERT_BUNDLE) +#if defined(BOTAN_HAS_CERTSTOR_FLATFILE) #include "test_certstor_utils.h" #include <botan/certstor_flatfile.h> @@ -19,6 +19,11 @@ namespace Botan_Tests { namespace { +std::string get_valid_ca_bundle_path() + { + return Test::data_file("x509/misc/certstor/valid_ca_bundle.pem"); + } + Test::Result open_certificate_store() { Test::Result result("Flatfile Certificate Store - Open Store"); @@ -26,7 +31,7 @@ Test::Result open_certificate_store() try { result.start_timer(); - Botan::Flatfile_Certificate_Store unused(BOTAN_SYSTEM_CERT_BUNDLE); + Botan::Flatfile_Certificate_Store unused(get_valid_ca_bundle_path()); result.end_timer(); result.test_gt("found some certificates", unused.all_subjects().size(), 0); } @@ -47,7 +52,7 @@ Test::Result find_certificate_by_pubkey_sha1() try { result.start_timer(); - Botan::Flatfile_Certificate_Store certstore(BOTAN_SYSTEM_CERT_BUNDLE); + Botan::Flatfile_Certificate_Store certstore(get_valid_ca_bundle_path()); auto cert = certstore.find_cert_by_pubkey_sha1(get_key_id()); result.end_timer(); @@ -65,7 +70,7 @@ Test::Result find_certificate_by_pubkey_sha1() result.test_throws("on invalid SHA1 hash data", [&] { - Botan::Flatfile_Certificate_Store certstore(BOTAN_SYSTEM_CERT_BUNDLE); + Botan::Flatfile_Certificate_Store certstore(get_valid_ca_bundle_path()); certstore.find_cert_by_pubkey_sha1({}); }); @@ -81,7 +86,7 @@ Test::Result find_cert_by_subject_dn() auto dn = get_dn(); result.start_timer(); - Botan::Flatfile_Certificate_Store certstore(BOTAN_SYSTEM_CERT_BUNDLE); + Botan::Flatfile_Certificate_Store certstore(get_valid_ca_bundle_path()); auto cert = certstore.find_cert(dn, std::vector<uint8_t>()); result.end_timer(); @@ -109,7 +114,7 @@ Test::Result find_cert_by_subject_dn_and_key_id() auto dn = get_dn(); result.start_timer(); - Botan::Flatfile_Certificate_Store certstore(BOTAN_SYSTEM_CERT_BUNDLE); + Botan::Flatfile_Certificate_Store certstore(get_valid_ca_bundle_path()); auto cert = certstore.find_cert(dn, get_key_id()); result.end_timer(); @@ -137,7 +142,7 @@ Test::Result find_certs_by_subject_dn_and_key_id() auto dn = get_dn(); result.start_timer(); - Botan::Flatfile_Certificate_Store certstore(BOTAN_SYSTEM_CERT_BUNDLE); + Botan::Flatfile_Certificate_Store certstore(get_valid_ca_bundle_path()); auto certs = certstore.find_all_certs(dn, get_key_id()); result.end_timer(); @@ -164,7 +169,7 @@ Test::Result find_all_subjects() try { result.start_timer(); - Botan::Flatfile_Certificate_Store certstore(BOTAN_SYSTEM_CERT_BUNDLE); + Botan::Flatfile_Certificate_Store certstore(get_valid_ca_bundle_path()); auto subjects = certstore.all_subjects(); result.end_timer(); @@ -202,7 +207,7 @@ Test::Result no_certificate_matches() auto kid = get_unknown_key_id(); result.start_timer(); - Botan::Flatfile_Certificate_Store certstore(BOTAN_SYSTEM_CERT_BUNDLE); + Botan::Flatfile_Certificate_Store certstore(get_valid_ca_bundle_path()); auto certs = certstore.find_all_certs(dn, kid); auto cert = certstore.find_cert(dn, kid); |