11#include <botan/pkix_types.h>
13#include <botan/internal/fmt.h>
24 std::string_view ip) {
25 if(!email_addr.empty()) {
47 if(type.empty() || value.empty()) {
53 }
else if(type ==
"RFC822") {
55 }
else if(type ==
"URI") {
57 }
else if(type ==
"DN") {
63 }
else if(type ==
"IP") {
88 std::multimap<std::string, std::string> names;
90 for(
const auto& nm : this->
dns()) {
91 names.emplace(
"DNS", nm);
94 for(
const auto& nm : this->
email()) {
95 names.emplace(
"RFC822", nm);
98 for(
const auto& nm : this->
uris()) {
99 names.emplace(
"URI", nm);
103 names.emplace(
"IP", ipv4.to_string());
107 names.emplace(
"IPv6", ipv6.to_string());
111 names.emplace(
"DN", nm.to_string());
115 names.emplace(othername.first.to_formatted_string(), othername.second.value());
122 std::multimap<std::string, std::string, std::less<>> r;
124 for(
const auto& c : this->
contents()) {
125 r.emplace(c.first, c.second);
146 auto set_to_vector = [](
const std::set<std::string>& s) -> std::vector<std::string> {
return {s.begin(), s.end()}; };
149 return set_to_vector(this->
dns());
150 }
else if(attr ==
"RFC822") {
151 return set_to_vector(this->
email());
152 }
else if(attr ==
"URI") {
153 return set_to_vector(this->
uris());
154 }
else if(attr ==
"DN") {
155 std::vector<std::string> ret;
158 ret.push_back(nm.to_string());
162 }
else if(attr ==
"IP") {
163 std::vector<std::string> ip_str;
165 ip_str.push_back(ipv4.to_string());
180 for(
const auto& rdn :
dn.rdns()) {
189 std::set<uint32_t> out;
190 for(
const auto& a : m_ipv4_addrs) {
191 out.insert(a.address());
const std::set< IPv6Address > & ipv6_addresses() const
Return the set of IPv6 addresses included in this alternative name.
const std::set< X509_DN > & directory_names() const
Return the set of directory names included in this alternative name.
std::string get_first_attribute(std::string_view attr) const
void add_dns(std::string_view dns)
Add a DNS name to this AlternativeName, parsing and validating the input.
std::set< std::string > dns() const
void add_ipv4_address(uint32_t ipv4)
Add an IP address to this alternative name.
void add_email(std::string_view addr)
Add an email address to this AlternativeName, parsing and validating the input.
std::set< uint32_t > ipv4_address() const
Return the set of IPv4 addresses included in this alternative name.
std::multimap< std::string, std::string > contents() const
std::vector< std::string > get_attribute(std::string_view attr) const
const std::set< std::pair< OID, ASN1_String > > & other_names() const
Return the set of "other names" whose value was a recognized ASN1_String type.
void add_uri(std::string_view uri)
Add a URI to this AlternativeName, parsing and validating the input.
void add_attribute(std::string_view type, std::string_view value)
std::multimap< std::string, std::string, std::less<> > get_attributes() const
void add_other_name(const OID &oid, const ASN1_String &value)
Add an "OtherName" identified by object identifier to this AlternativeName.
std::set< std::string > uris() const
void add_othername(const OID &oid, std::string_view value, ASN1_Type type)
std::set< std::string > email() const
const std::set< IPv4Address > & ipv4_addresses() const
Return the set of IPv4 addresses included in this alternative name.
void add_dn(const X509_DN &dn)
Add a directory name to this AlternativeName.
AlternativeName()=default
Create an empty name.
bool has_field(std::string_view attr) const
static std::optional< IPv4Address > from_string(std::string_view str)
void add_rdn(std::vector< std::pair< OID, ASN1_String > > rdn)
static std::optional< X509_DN > parse(std::string_view str)
std::string fmt(std::string_view format, const T &... args)