Skip to content

Commit 9f5be09

Browse files
committed
PHP5.6 change serveral TLS verfication defaults
1 parent bfccc98 commit 9f5be09

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

tests/connect/standalone-ssl-0001.phpt

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,24 @@
11
--TEST--
2-
Connect to MongoDB with using SSL
2+
Connect to MongoDB with using SSL without verifying anything
33
--SKIPIF--
44
<?php require "tests/utils/basic-skipif.inc"?>
55
--FILE--
66
<?php
77
require_once "tests/utils/basic.inc";
88

9+
$SSL_DIR = realpath(__DIR__ . "/" . "./../../scripts/ssl/");
10+
$opts = array(
11+
"ssl" => array(
12+
"verify_peer" => false,
13+
"verify_peer_name" => false,
14+
"allow_self_signed" => true,
15+
),
16+
);
17+
$context = stream_context_create($opts);
18+
919
$dsn = sprintf("%s/?ssl=true", MONGODB_STANDALONE_SSL_URI);
1020

11-
$manager = new MongoDB\Driver\Manager($dsn);
21+
$manager = new MongoDB\Driver\Manager($dsn, array(), array("context" => $context));
1222

1323
$bulk = new MongoDB\Driver\BulkWrite;
1424

tests/connect/standalone-ssl-0002.phpt

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,21 @@ function isValid(array $cert) {
2424

2525
$opts = array(
2626
"ssl" => array(
27-
"peer_name" => "MongoDB",
27+
"peer_name" => "WRONG PEER NAME",
2828
"verify_peer" => true,
2929
"verify_peer_name" => true,
3030
"allow_self_signed" => false,
3131
"cafile" => $SSL_DIR . "/ca.pem", /* Defaults to openssl.cafile */
3232
"capath" => $SSL_DIR, /* Defaults to openssl.capath */
3333
"local_cert" => $SSL_DIR . "/client.pem",
3434
"passphrase" => "Very secretive client.pem passphrase",
35-
"CN_match" => "Common Name (CN) match",
3635
"verify_depth" => 5,
3736
"ciphers" => "HIGH:!EXPORT:!aNULL@STRENGTH",
3837
"capture_peer_cert" => true,
3938
"capture_peer_cert_chain" => true,
4039
"SNI_enabled" => true,
4140
"disable_compression" => false,
42-
"peer_fingerprint" => "0d6dbd95",
41+
"peer_fingerprint" => strtolower("FC16D0861C31D29E90A8A5C832469AB10EE7F4DD"),
4342
),
4443
);
4544
$context = stream_context_create($opts);
@@ -55,7 +54,7 @@ echo throws(function() use($manager) {
5554

5655

5756
echo "Changing to server\n";
58-
stream_context_set_option($context, "ssl", "CN_match", "server");
57+
stream_context_set_option($context, "ssl", "peer_name", "server");
5958
$bulk = new MongoDB\Driver\BulkWrite;
6059
$bulk->insert(array("my" => "value"));
6160
$retval = $manager->executeBulkWrite(NS, $bulk);

tests/connect/standalone-x509-0001.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,21 @@ $SSL_DIR = realpath(__DIR__ . "/" . "./../../scripts/ssl/");
1010

1111
$opts = array(
1212
"ssl" => array(
13-
"peer_name" => "MongoDB",
13+
"peer_name" => "server",
1414
"verify_peer" => true,
1515
"verify_peer_name" => true,
1616
"allow_self_signed" => false,
1717
"cafile" => $SSL_DIR . "/ca.pem", /* Defaults to openssl.cafile */
1818
"capath" => $SSL_DIR, /* Defaults to openssl.capath */
1919
"local_cert" => $SSL_DIR . "/client.pem",
2020
"passphrase" => "qwerty",
21-
"CN_match" => "server",
2221
"verify_depth" => 5,
2322
"ciphers" => "HIGH:!EXPORT:!aNULL@STRENGTH",
2423
"capture_peer_cert" => true,
2524
"capture_peer_cert_chain" => true,
2625
"SNI_enabled" => true,
2726
"disable_compression" => false,
28-
"peer_fingerprint" => "0d6dbd95",
27+
"peer_fingerprint" => strtolower("FC16D0861C31D29E90A8A5C832469AB10EE7F4DD"),
2928
),
3029
);
3130
$context = stream_context_create($opts);

tests/connect/standalone-x509-0002.phpt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,21 @@ $SSL_DIR = realpath(__DIR__ . "/" . "./../../scripts/ssl/");
1010

1111
$opts = array(
1212
"ssl" => array(
13-
"peer_name" => "MongoDB",
13+
"peer_name" => "server",
1414
"verify_peer" => true,
1515
"verify_peer_name" => true,
1616
"allow_self_signed" => false,
1717
"cafile" => $SSL_DIR . "/ca.pem", /* Defaults to openssl.cafile */
1818
"capath" => $SSL_DIR, /* Defaults to openssl.capath */
1919
"local_cert" => $SSL_DIR . "/client.pem",
2020
"passphrase" => "qwerty",
21-
"CN_match" => "server",
2221
"verify_depth" => 5,
2322
"ciphers" => "HIGH:!EXPORT:!aNULL@STRENGTH",
2423
"capture_peer_cert" => true,
2524
"capture_peer_cert_chain" => true,
2625
"SNI_enabled" => true,
2726
"disable_compression" => false,
28-
"peer_fingerprint" => "0d6dbd95",
27+
"peer_fingerprint" => strtolower("FC16D0861C31D29E90A8A5C832469AB10EE7F4DD"),
2928
),
3029
);
3130
$context = stream_context_create($opts);

0 commit comments

Comments
 (0)