MCPcopy Create free account
hub / github.com/apache/trafficserver / addSANExtToCert

Function addSANExtToCert

plugins/certifier/certifier.cc:331–344  ·  view source on GitHub ↗

* Local helper function that adds a Subject Alternative Name field into a * certificate. * * @param[out] cert * @param[in] dnsName */

Source from the content-addressed store, hash-verified

329 * @param[in] dnsName
330 */
331static void
332addSANExtToCert(X509 *cert, std::string_view dnsName)
333{
334 Dbg(dbg_ctl, "Adding SAN extension to the cert");
335 GENERAL_NAMES *generalNames = sk_GENERAL_NAME_new_null();
336 GENERAL_NAME *generalName = GENERAL_NAME_new();
337 ASN1_IA5STRING *ia5 = ASN1_IA5STRING_new();
338 ASN1_STRING_set(ia5, dnsName.data(), dnsName.length());
339 // generalName owns ia5 after this call
340 GENERAL_NAME_set0_value(generalName, GEN_DNS, ia5);
341 sk_GENERAL_NAME_push(generalNames, generalName);
342 X509_add1_ext_i2d(cert, NID_subject_alt_name, generalNames, 0, X509V3_ADD_DEFAULT);
343 sk_GENERAL_NAME_pop_free(generalNames, GENERAL_NAME_free);
344}
345
346/// Local helper function that generates a X509 certificate based on SNI
347static scoped_X509

Callers 1

mkcrtFunction · 0.85

Calls 2

dataMethod · 0.45
lengthMethod · 0.45

Tested by

no test coverage detected