|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #64666 Certificate not captured if present, but CN_match fails
Submitted: 2013-04-18 11:37 UTC Modified: 2021-06-13 04:22 UTC
From: douglas dot wright at pre-school dot org dot uk Assigned: cmb (profile)
Status: No Feedback Package: Streams related
PHP Version: 5.4.14 OS: Windows 7
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: douglas dot wright at pre-school dot org dot uk
New email:
PHP Version: OS:


 [2013-04-18 11:37 UTC] douglas dot wright at pre-school dot org dot uk
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:
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
foreach (['', ''] as $cn) {
  echo "Testing {$cn} against";
  $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://", $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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2021-06-02 11:06 UTC]
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-06-02 11:06 UTC]
Is this still an issue with any of the actively supported PHP

[1] <>
 [2021-06-13 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Jun 22 02:01:28 2024 UTC