MCPcopy Create free account
hub / github.com/Icinga/icinga2 / GetSubjectAltNames

Function GetSubjectAltNames

lib/base/tlsutility.cpp:1147–1171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1145}
1146
1147Array::Ptr GetSubjectAltNames(const std::shared_ptr<X509>& cert)
1148{
1149 GENERAL_NAMES* subjectAltNames = (GENERAL_NAMES*)X509_get_ext_d2i(cert.get(), NID_subject_alt_name, nullptr, nullptr);
1150
1151 Array::Ptr sans = new Array();
1152
1153 for (int i = 0; i < sk_GENERAL_NAME_num(subjectAltNames); i++) {
1154 GENERAL_NAME* gen = sk_GENERAL_NAME_value(subjectAltNames, i);
1155 if (gen->type == GEN_URI || gen->type == GEN_DNS || gen->type == GEN_EMAIL) {
1156 ASN1_IA5STRING *asn1_str = gen->d.uniformResourceIdentifier;
1157
1158#if OPENSSL_VERSION_NUMBER < 0x10100000L
1159 String san = Convert::ToString(ASN1_STRING_data(asn1_str));
1160#else /* OPENSSL_VERSION_NUMBER < 0x10100000L */
1161 String san = Convert::ToString(ASN1_STRING_get0_data(asn1_str));
1162#endif /* OPENSSL_VERSION_NUMBER < 0x10100000L */
1163
1164 sans->Add(san);
1165 }
1166 }
1167
1168 GENERAL_NAMES_free(subjectAltNames);
1169
1170 return sans;
1171}
1172
1173}

Callers 1

Calls 2

getMethod · 0.45
AddMethod · 0.45

Tested by

no test coverage detected