Skip to content

Commit

Permalink
Add a test for alt DN encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
randombit committed May 8, 2024
1 parent c0eda69 commit 75a0deb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/tests/unit_x509.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,11 @@ Test::Result test_pkcs10_ext(const Botan::Private_Key& key,
Botan::AlternativeName alt_name;
alt_name.add_attribute("DNS", "bonus.example.org");

Botan::X509_DN alt_dn;
alt_dn.add_attribute("X520.CommonName", "alt_cn");
alt_dn.add_attribute("X520.Organization", "testing");
alt_name.add_dn(alt_dn);

opts.extensions.add(std::make_unique<Botan::Cert_Extension::Subject_Alternative_Name>(alt_name));

const auto req = Botan::X509::create_cert_req(opts, key, hash_fn, rng);
Expand All @@ -842,6 +847,9 @@ Test::Result test_pkcs10_ext(const Botan::Private_Key& key,
result.test_eq("Expected DNS name 3", alt_dns_names.at(3), "more2.example.org");
}

result.test_eq("Expected number of alt DNs", req.subject_alt_name().directory_names().size(), 1);
result.confirm("Alt DN is correct", *req.subject_alt_name().directory_names().begin() == alt_dn);

return result;
}

Expand Down

0 comments on commit 75a0deb

Please sign in to comment.