Bug #64666 [Opn->Fbk]: Certificate not captured if present, but CN_match fails
| From: | cmb@php.net | Date: | Wed, 02 Jun 2021 11:06:09 +0000 |
| Subject: | Bug #64666 [Opn->Fbk]: Certificate not captured if present, but CN_match fails | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-234163@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=64666&edit=1
ID: 64666
Updated by: cmb@php.net
Reported by: douglas dot wright at pre-school dot org dot uk
Summary: Certificate not captured if present, but CN_match
fails
-Status: Open
+Status: Feedback
Type: Bug
Package: Streams related
Operating System: Windows 7
PHP Version: 5.4.14
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Is this still an issue with any of the actively supported PHP
versions[1]?
[1] <https://www.php.net/supported-versions.php>
Previous Comments:
------------------------------------------------------------------------
[2013-04-18 11:37:46] douglas dot wright at pre-school dot org dot uk
Description:
------------
If connecting to a server that has a certificate that doesn't match the expected hostname, then
the certificate is not captured. For logging/troubleshooting purposes this should still work.
Test script:
---------------
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
foreach (['www.pre-school.org.uk', 'www.pre-school.org'] as $cn) {
echo "Testing {$cn} against www.pre-school.org.uk...";
$context = stream_context_create(['ssl' => ['SNI_enabled' =>
true,
'verify_peer' => true,
'CN_match' => $cn,
'cafile' =>
'keys/Mozilla-Cert-Bundle.pem',
'capture_peer_cert' => true,
'capture_peer_cert_chain' => true]]);
$conn = stream_socket_client("tcp://www.pre-school.org.uk:443", $errNo, $errStr, 5,
STREAM_CLIENT_CONNECT, $context);
@stream_socket_enable_crypto($conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT);
echo isset(stream_context_get_options($conn)["ssl"]["peer_certificate"]) ?
"captured\r\n" : "NOT captured\r\n";
}
Expected result:
----------------
Certificate captured under both success and failure
Actual result:
--------------
Certificate captured under success only
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=64666&edit=1