用于OpenLdap配置的Php证书SSL

用于OpenLdap配置的Php证书SSL,php,ssl,openldap,Php,Ssl,Openldap,我在本地与LinuxMint合作,并在virtualbox中安装了带有openldap的UbuntuServer。现在我按照这个指南进行配置 TLS/SSL身份验证。 我已在客户端(linuxmint)中安装了Xampp,并使用以下配置/etc/ldap/ldap.conf: TLS_CACERT /etc/ssl/certs/192.168.1.46_slapd_cert.pem TLS_REQCERT never 我尝试连接php函数: <?php // This code

我在本地与LinuxMint合作,并在virtualbox中安装了带有openldap的UbuntuServer。现在我按照这个指南进行配置 TLS/SSL身份验证。 我已在客户端(linuxmint)中安装了Xampp,并使用以下配置/etc/ldap/ldap.conf:

TLS_CACERT      /etc/ssl/certs/192.168.1.46_slapd_cert.pem
TLS_REQCERT never
我尝试连接php函数:

<?php
// This code goes directly to the 636 SSL port

$ldaphost = "ldaps://192.168.1.46";
$ldapUsername  = "cn=admin,dc=company,dc=com";
$ldapPassword = "secret";


$ds = ldap_connect($ldaphost);

if(!ldap_set_option($ds, LDAP_OPT_PROTOCOL_VERSION, 3)){
print "Could not set LDAPv3\r\n";
}
else {
// now we need to bind to the ldap server
$bth = ldap_bind($ds, $ldapUsername, $ldapPassword) or die("\r\nCould not connect to LDAP server\r\n");
}
?>
它起作用了!!
但是通过php为什么?。我尝试在/opt/lampp/etc/openldap中配置ldap.conf,但没有结果。

我在centos中使用openldap和apache/php。也许是相似的

  • 我的ldap.conf位于/etc/ldap.conf中
  • 我已配置*TLS\U请求证书允许*
  • 我必须在同一目录中生成证书的哈希作为符号链接:
  • ln-s/etc/ssl/certs/192.168.1.46_slapd_cert.pem`opensslx509-hash-noout-in/etc/ssl/certs/192.168.1.46_slapd_cert.pem`.0
    
    在我的Ubuntu(不支持ldapsupport)上存在c_rehash功能。如果我在那里安装了撤销列表,我必须使用此函数以以下方式重新刷新所有撤销列表:

    cd/etc/ssl/certs/
    c_rehash/etc/ssl/certs/
    
    也许它为您的CA创建了正确的哈希

    ldapsearch -x -H ldaps://192.168.1.46 -b "cn=company,cn=com"