* Local helper function that adds a Subject Alternative Name field into a * certificate. * * @param[out] cert * @param[in] dnsName */
| 329 | * @param[in] dnsName |
| 330 | */ |
| 331 | static void |
| 332 | addSANExtToCert(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 |
| 347 | static scoped_X509 |