14 static const std::string IP_ADDRESS_PREFIX =
"iPAddress:";
15 static const std::string DNS_NAME_PREFIX =
"dNSName:";
30 if (str.starts_with(IP_ADDRESS_PREFIX))
32 return {str.substr(IP_ADDRESS_PREFIX.size()),
true};
34 else if (str.starts_with(DNS_NAME_PREFIX))
36 return {str.substr(DNS_NAME_PREFIX.size()),
false};
40 throw std::logic_error(fmt::format(
41 "SAN could not be parsed: {}, must be (iPAddress|dNSName):VALUE", str));
45 static std::vector<SubjectAltName> sans_from_string_list(
46 const std::vector<std::string>& list)
48 std::vector<SubjectAltName> sans = {};
49 for (
const auto& l : list)
51 sans.push_back(san_from_string(l));
59struct formatter<
ccf::crypto::SubjectAltName>
61 template <
typename ParseContext>
62 constexpr auto parse(ParseContext& ctx)
67 template <
typename FormatContext>
69 ->
decltype(ctx.out())
80 return format_to(ctx.out(),
"{}:{}", prefix, san.san);
#define DECLARE_JSON_REQUIRED_FIELDS(TYPE,...)
Definition json.h:714
#define DECLARE_JSON_TYPE(TYPE)
Definition json.h:663
Definition app_interface.h:14
bool operator!=(const SubjectAltName &other) const =default
std::string san
Definition san.h:19
bool operator==(const SubjectAltName &other) const =default
bool is_ip
Definition san.h:20