Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions ext/ldap/tests/ldap_start_tls_rc_max_version.phpt
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
--TEST--
ldap_start_tls() - Basic ldap_start_tls test
ldap_start_tls() - TLS max version from LDAPCONF is enforced
--EXTENSIONS--
ldap
--ENV--
LDAPCONF={PWD}/ldap_start_tls_rc_max_version.conf
--SKIPIF--
<?php
// Skip in CI for now as adding olcTLSProtocolMin does not seem to work (needs investigation)
if (getenv('CI')) {
die("Skip in CI for now");
}
$require_vendor = [
"name" => "OpenLDAP",
"min_version" => 20600,
];
require_once __DIR__ .'/skipifbindfailure.inc';
// GnuTLS backend ignores TLS protocol min and max options on both client and server
$link = ldap_connect($uri);
if (!ldap_get_option($link, LDAP_OPT_X_TLS_PACKAGE, $package) || $package === 'GnuTLS') {
die("skip Requires libldap TLS backend that supports TLS protocol version limits");
}
?>
--FILE--
<?php
Expand Down
2 changes: 2 additions & 0 deletions ext/ldap/tests/ldap_start_tls_rc_version_inherit.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
TLS_PROTOCOL_MIN 3.1
TLS_PROTOCOL_MAX 3.2
60 changes: 60 additions & 0 deletions ext/ldap/tests/ldap_start_tls_rc_version_inherit.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
--TEST--
ldap_start_tls() - TLS protocol version options from LDAPCONF are inherited
--EXTENSIONS--
ldap
--ENV--
LDAPCONF={PWD}/ldap_start_tls_rc_version_inherit.conf
--SKIPIF--
<?php
if (!defined('LDAP_OPT_X_TLS_PROTOCOL_MAX')) {
die("skip Requires LDAP_OPT_X_TLS_PROTOCOL_MAX");
}
?>
--FILE--
<?php
require_once "connect.inc";

function dump_versions($link) {
ldap_get_option($link, LDAP_OPT_X_TLS_PROTOCOL_MIN, $min);
ldap_get_option($link, LDAP_OPT_X_TLS_PROTOCOL_MAX, $max);
var_dump($min === LDAP_OPT_X_TLS_PROTOCOL_TLS1_0, $max);
}

// The result of ldap_start_tls() depends on the server and TLS backend so only options are checked

// Not inherited before TLS context is created
$link = ldap_connect($uri);
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
dump_versions($link);

// No TLS option set on the link
@ldap_start_tls($link);
dump_versions($link);

// Unrelated TLS option set on the link
$link = ldap_connect($uri);
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
ldap_set_option($link, LDAP_OPT_X_TLS_REQUIRE_CERT, LDAP_OPT_X_TLS_NEVER);
@ldap_start_tls($link);
dump_versions($link);

// Version set on the link is not overwritten
$link = ldap_connect($uri);
ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, $protocol_version);
ldap_set_option($link, LDAP_OPT_X_TLS_PROTOCOL_MAX, LDAP_OPT_X_TLS_PROTOCOL_TLS1_2);
@ldap_start_tls($link);
dump_versions($link);

var_dump(LDAP_OPT_X_TLS_PROTOCOL_TLS1_1, LDAP_OPT_X_TLS_PROTOCOL_TLS1_2);
?>
--EXPECT--
bool(false)
int(0)
bool(true)
int(770)
bool(true)
int(770)
bool(true)
int(771)
int(770)
int(771)
Loading