PHP ldap_connect 使用 ldaps 连接到 Active Directory 时出现未知 CA 错误

问题描述 投票:0回答:0

我正在尝试在 Windows 2012 服务器上使用 PHP 7 连接到 MS Active Directory(运行 apache 2.4,但这应该与我遇到的问题无关)。

我还应该注意,我可以使用命令行和 apache 服务器中的非安全 LDAP 从 PHP 连接到 AD。

当我执行以下 PHP 测试文件时,源:http://muzso.hu/2012/04/02/php-ldap-ssl-ldaps-authentication-in-windows-running-apache,从 Web 服务器上的命令行:


$AD_search_bind_DN = 'CN=someuser,OU=Users,DC=example,DC=com';
$AD_search_bind_PW = 'secret123';
ini_set('display_errors', 1);
error_reporting(E_ALL);
ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);
$conn = ldap_connect('ldaps://SomeDC.example.com/') or die("Failed to connect to ldap server.");
ldap_set_option(NULL, LDAP_OPT_PROTOCOL_VERSION, 3);
ldap_bind($conn, $AD_search_bind_DN, $AD_search_bind_PW) or die("Failed to bind to ldap server: " + ldap_error($conn));
echo "Successful LDAP bind.";

我得到以下输出(我突出显示了错误):


ldap_url_parse_ext(ldap://localhost/)
ldap_init:尝试 %SYSCONFDIR%\ldap.conf
ldap_init:HOME 环境为 NULL
ldap_init:尝试 ldaprc
ldap_init:LDAPCONF 环境为 NULL
ldap_init:LDAPRC 环境为 NULL
ldap_创建
ldap_url_parse_ext(ldaps://SomeDC.example.com/)
ldap_sasl_bind_s
ldap_sasl_bind
ldap_send_initial_request
ldap_new_connection 1 1 0
ldap_int_open_connection
ldap_connect_to_host:TCP SomeDC.example.com:636
ldap_new_socket:244
ldap_prepare_socket:244
ldap_connect_to_host:尝试{删除某些DC的IP地址}:636
ldap_pvt_connect:fd:244 tm:-1异步:0
尝试连接:
连接成功
TLS 跟踪:SSL_connect:在/连接初始化之前
TLS 跟踪:SSL_connect:SSLv2/v3 写入客户端问候 A
TLS 跟踪:SSL_connect:SSLv3 读取服务器问候 A
TLS 证书验证:深度:1,错误:20,主题:/DC=com/DC=example/C
N=Self_Named-SHA256-SubCA,颁发者:/CN=ITSS-Ent-SHA256-Root
TLS证书验证:错误,无法获取本地颁发者证书
TLS 跟踪:SSL3 警报写入:致命:未知 CA
TLS 跟踪:SSL_connect:错误中的错误
TLS 跟踪:SSL_connect:错误中的错误
TLS:无法连接:错误:14090086:SSL
例程:ssl3_get_server_certificate:证书验证失败(无法获取本地颁发者证书)。
ldap_err2string
PHP 警告:ldap_bind():无法绑定到服务器:无法联系第 10 行 C: est_bind.php 中的 LDAP 服务器


我的 php.ini 文件中的 php_ldap 和 php_openssl 扩展均未注释。

我有 DER 和 PEM 格式的 AD CA 证书副本,但我不确定将这些文件放在我的 Web 服务器上的何处。有很多与 Linux 操作系统相关的帖子,只是简单地说将“TLS_CACERT C:\openldap\syscon

php apache active-directory openssl windows-server-2012
© www.soinside.com 2019 - 2024. All rights reserved.