Skip to content

Commit 83f3330

Browse files
committed
LibreSSL cannot extract username subject from X509 certs
1 parent 28c717b commit 83f3330

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

tests/connect/standalone-x509-extract_username-001.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Connect to MongoDB with SSL and X509 auth and username retrieved from cert
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php NEEDS_SSL(['OpenSSL', 'Secure Transport', 'Secure Channel']); ?>
56
<?php NEEDS('STANDALONE_X509'); ?>
67
--FILE--
78
<?php

tests/connect/standalone-x509-extract_username-002.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Connect to MongoDB with SSL and X509 auth and username retrieved from cert (stream context)
33
--SKIPIF--
44
<?php require __DIR__ . "/../utils/basic-skipif.inc"; ?>
5+
<?php NEEDS_SSL(['OpenSSL', 'Secure Transport', 'Secure Channel']); ?>
56
<?php NEEDS('STANDALONE_X509'); ?>
67
--FILE--
78
<?php

tests/utils/tools.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,26 @@ function NEEDS_STORAGE_ENGINE($uri, $engine) {
175175
}
176176
}
177177

178+
/* Checks that libmongoc is using one of the following SSL libraries, denoted by
179+
* the value of "libmongoc SSL library" in phpinfo() output. Possible values are
180+
* "OpenSSL", "LibreSSL", "Secure Transport", and "Secure Channel". */
181+
function NEEDS_SSL(array $libs)
182+
{
183+
ob_start();
184+
phpinfo(INFO_MODULES);
185+
$info = ob_get_clean();
186+
187+
$pattern = sprintf('/^%s([\w ]+)$/m', preg_quote('libmongoc SSL library => '));
188+
189+
if (preg_match($pattern, $info, $matches) !== 1) {
190+
exit('skip Could not determine SSL library');
191+
}
192+
193+
if (!in_array($matches[1], $libs)) {
194+
exit('skip Needs SSL library ' . implode(', ', $libs) . ', but found ' . $matches[1]);
195+
}
196+
}
197+
178198
function CLEANUP($uri, $dbname = DATABASE_NAME, $collname = COLLECTION_NAME) {
179199
try {
180200
$manager = new MongoDB\Driver\Manager($uri);

0 commit comments

Comments
 (0)