|  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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
50 + 32 = ?
Subscribe to this entry?

 [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: Mon Jun 17 14:01:31 2024 UTC