|
130 | 130 | #define PHP_X509_NAME_ENTRY_TO_UTF8(ne, i, out) \
|
131 | 131 | ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(X509_NAME_get_entry(ne, i)))
|
132 | 132 |
|
| 133 | +#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON) |
133 | 134 | /* Used for IPv6 Address peer verification */
|
134 | 135 | #define EXPAND_IPV6_ADDRESS(_str, _bytes) \
|
135 | 136 | do { \
|
|
144 | 145 | _bytes[14] << 8 | _bytes[15] \
|
145 | 146 | ); \
|
146 | 147 | } while(0)
|
| 148 | +#define HAVE_IPV6_SAN 1 |
| 149 | +#endif |
147 | 150 |
|
148 | 151 | #if PHP_OPENSSL_API_VERSION < 0x10100
|
149 | 152 | static RSA *php_openssl_tmp_rsa_cb(SSL *s, int is_export, int keylength);
|
@@ -456,16 +459,17 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) /
|
456 | 459 | GENERAL_NAMES *alt_names = X509_get_ext_d2i(peer, NID_subject_alt_name, 0, 0);
|
457 | 460 | int alt_name_count = sk_GENERAL_NAME_num(alt_names);
|
458 | 461 |
|
459 |
| -#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON) |
| 462 | +#ifdef HAVE_IPV6_SAN |
460 | 463 | /* detect if subject name is an IPv6 address and expand once if required */
|
461 |
| - char subject_name_ipv6_expanded[40]; |
462 |
| - unsigned char ipv6[16]; |
463 |
| - bool subject_name_is_ipv6 = false; |
464 |
| - subject_name_ipv6_expanded[0] = 0; |
| 464 | + char subject_name_ipv6_expanded[40]; |
| 465 | + unsigned char ipv6[16]; |
| 466 | + bool subject_name_is_ipv6 = false; |
| 467 | + subject_name_ipv6_expanded[0] = 0; |
| 468 | + |
465 | 469 | if (inet_pton(AF_INET6, subject_name, &ipv6)) {
|
466 |
| - EXPAND_IPV6_ADDRESS(subject_name_ipv6_expanded, ipv6); |
467 |
| - subject_name_is_ipv6 = true; |
468 |
| - } |
| 470 | + EXPAND_IPV6_ADDRESS(subject_name_ipv6_expanded, ipv6); |
| 471 | + subject_name_is_ipv6 = true; |
| 472 | + } |
469 | 473 | #endif
|
470 | 474 |
|
471 | 475 | for (i = 0; i < alt_name_count; i++) {
|
@@ -506,7 +510,7 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) /
|
506 | 510 | return 1;
|
507 | 511 | }
|
508 | 512 | }
|
509 |
| -#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON) |
| 513 | +#ifdef HAVE_IPV6_SAN |
510 | 514 | else if (san->d.ip->length == 16 && subject_name_is_ipv6) {
|
511 | 515 | ipbuffer[0] = 0;
|
512 | 516 | EXPAND_IPV6_ADDRESS(ipbuffer, san->d.iPAddress->data);
|
|
0 commit comments