MCPcopy Create free account
hub / github.com/apache/httpd / md_cert_get_alt_names

Function md_cert_get_alt_names

modules/md/md_crypt.c:1363–1419  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1361}
1362
1363apr_status_t md_cert_get_alt_names(apr_array_header_t **pnames, const md_cert_t *cert, apr_pool_t *p)
1364{
1365 apr_array_header_t *names;
1366 apr_status_t rv = APR_ENOENT;
1367 STACK_OF(GENERAL_NAME) *xalt_names;
1368 unsigned char *buf;
1369 int i;
1370
1371 xalt_names = X509_get_ext_d2i(cert->x509, NID_subject_alt_name, NULL, NULL);
1372 if (xalt_names) {
1373 GENERAL_NAME *cval;
1374 const unsigned char *ip;
1375 int len;
1376
1377 names = apr_array_make(p, sk_GENERAL_NAME_num(xalt_names), sizeof(char *));
1378 for (i = 0; i < sk_GENERAL_NAME_num(xalt_names); ++i) {
1379 cval = sk_GENERAL_NAME_value(xalt_names, i);
1380 switch (cval->type) {
1381 case GEN_DNS:
1382 case GEN_URI:
1383 ASN1_STRING_to_UTF8(&buf, cval->d.ia5);
1384 APR_ARRAY_PUSH(names, const char *) = apr_pstrdup(p, (char*)buf);
1385 OPENSSL_free(buf);
1386 break;
1387 case GEN_IPADD:
1388 len = ASN1_STRING_length(cval->d.iPAddress);
1389#if OPENSSL_VERSION_NUMBER < 0x10100000L
1390 ip = ASN1_STRING_data(cval->d.iPAddress);
1391#else
1392 ip = ASN1_STRING_get0_data(cval->d.iPAddress);
1393#endif
1394 if (len == 4) /* IPv4 address */
1395 APR_ARRAY_PUSH(names, const char *) = apr_psprintf(p, "%u.%u.%u.%u",
1396 ip[0], ip[1], ip[2], ip[3]);
1397 else if (len == 16) /* IPv6 address */
1398 APR_ARRAY_PUSH(names, const char *) = apr_psprintf(p, "%02x%02x%02x%02x:"
1399 "%02x%02x%02x%02x:"
1400 "%02x%02x%02x%02x:"
1401 "%02x%02x%02x%02x",
1402 ip[0], ip[1], ip[2], ip[3],
1403 ip[4], ip[5], ip[6], ip[7],
1404 ip[8], ip[9], ip[10], ip[11],
1405 ip[12], ip[13], ip[14], ip[15]);
1406 else {
1407 ; /* Unknown address type - Log? Assert? */
1408 }
1409 break;
1410 default:
1411 break;
1412 }
1413 }
1414 sk_GENERAL_NAME_pop_free(xalt_names, GENERAL_NAME_free);
1415 rv = APR_SUCCESS;
1416 }
1417 *pnames = (APR_SUCCESS == rv)? names : NULL;
1418 return rv;
1419}
1420

Callers 3

md_cert_covers_domainFunction · 0.85
md_cert_covers_mdFunction · 0.85
pubcert_loadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected