|
115 | 115 | #define PHP_X509_NAME_ENTRY_TO_UTF8(ne, i, out) \
|
116 | 116 | ASN1_STRING_to_UTF8(&out, X509_NAME_ENTRY_get_data(X509_NAME_get_entry(ne, i)))
|
117 | 117 |
|
| 118 | +#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON) |
118 | 119 | /* Used for IPv6 Address peer verification */
|
119 | 120 | #define EXPAND_IPV6_ADDRESS(_str, _bytes) \
|
120 | 121 | do { \
|
|
129 | 130 | _bytes[14] << 8 | _bytes[15] \
|
130 | 131 | ); \
|
131 | 132 | } while(0)
|
| 133 | +#define HAVE_IPV6_SAN 1 |
| 134 | +#endif |
132 | 135 |
|
133 | 136 | #if PHP_OPENSSL_API_VERSION < 0x10100
|
134 | 137 | static RSA *php_openssl_tmp_rsa_cb(SSL *s, int is_export, int keylength);
|
@@ -441,16 +444,17 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) /
|
441 | 444 | GENERAL_NAMES *alt_names = X509_get_ext_d2i(peer, NID_subject_alt_name, 0, 0);
|
442 | 445 | int alt_name_count = sk_GENERAL_NAME_num(alt_names);
|
443 | 446 |
|
444 |
| -#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON) |
| 447 | +#ifdef HAVE_IPV6_SAN |
445 | 448 | /* detect if subject name is an IPv6 address and expand once if required */
|
446 |
| - char subject_name_ipv6_expanded[40]; |
447 |
| - unsigned char ipv6[16]; |
448 |
| - bool subject_name_is_ipv6 = false; |
449 |
| - subject_name_ipv6_expanded[0] = 0; |
| 449 | + char subject_name_ipv6_expanded[40]; |
| 450 | + unsigned char ipv6[16]; |
| 451 | + bool subject_name_is_ipv6 = false; |
| 452 | + subject_name_ipv6_expanded[0] = 0; |
| 453 | + |
450 | 454 | if (inet_pton(AF_INET6, subject_name, &ipv6)) {
|
451 |
| - EXPAND_IPV6_ADDRESS(subject_name_ipv6_expanded, ipv6); |
452 |
| - subject_name_is_ipv6 = true; |
453 |
| - } |
| 455 | + EXPAND_IPV6_ADDRESS(subject_name_ipv6_expanded, ipv6); |
| 456 | + subject_name_is_ipv6 = true; |
| 457 | + } |
454 | 458 | #endif
|
455 | 459 |
|
456 | 460 | for (i = 0; i < alt_name_count; i++) {
|
@@ -491,7 +495,7 @@ static bool php_openssl_matches_san_list(X509 *peer, const char *subject_name) /
|
491 | 495 | return 1;
|
492 | 496 | }
|
493 | 497 | }
|
494 |
| -#if defined(HAVE_IPV6) && defined(HAVE_INET_PTON) |
| 498 | +#ifdef HAVE_IPV6_SAN |
495 | 499 | else if (san->d.ip->length == 16 && subject_name_is_ipv6) {
|
496 | 500 | ipbuffer[0] = 0;
|
497 | 501 | EXPAND_IPV6_ADDRESS(ipbuffer, san->d.iPAddress->data);
|
|
0 commit comments