验证LDAPS连接的自签名证书

Ana*_*pta 7 php ldap active-directory client-certificates ssl-certificate

我想从Linux(Linux 3.2.0-4-amd64#1 SMP Debian 3.2.51-1 x86_64 GNU/Linux)客户端到Windows 2012服务器建立安全的ldap连接(ldaps),以更改活动中的用户密码目录,通过PHP.为此,我在服务器上创建了一个自签名证书(使用Windows Server Manager),但是当我尝试连接时,我收到以下错误(通过打开调试选项:) ldap_set_option(NULL, LDAP_OPT_DEBUG_LEVEL, 7);:

ldap_create                                                                 
ldap_url_parse_ext(ldaps://xxx.xxx.xxx.xxx)                                 
ldap_bind_s                                                                 
ldap_simple_bind_s                                                          
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 xxx.xxx.xxx.xxx:636                               
ldap_new_socket: 3                                                          
ldap_prepare_socket: 3                                                      
ldap_connect_to_host: Trying xxx.xxx.xxx.xxx:636                            
ldap_pvt_connect: fd: 3 tm: -1 async: 0                                     
TLS: peer cert untrusted or revoked (0x42)                                  
TLS: can't connect: (unknown error code).                                   
ldap_err2string                                                             
PHP Warning:  ldap_bind(): Unable to bind to server 
Run Code Online (Sandbox Code Playgroud)

似乎客户端无法信任证书,因为它是自签名的.

我应采取哪些步骤来建立安全连接?客户端证书存储在/etc/ssl/certs/ca-certificates.crt

Nae*_*Dus 7

您必须明确告诉LDAP客户端忽略不受信任的证书.您可以通过将以下内容添加到ldap.conf文件中来执行此操作:

TLS_REQCERT never
Run Code Online (Sandbox Code Playgroud)

但是,这种解决方案并不是首选.您应该将所需的CA root添加到您的客户端,并确保证书是正确生成的,其中包含服务器的名称(如果我的内存为我提供完整的CA链),否则不会阻止某人执行MITM攻击.