用于 OpenLdap 配置的 Php 证书 SSL


Php Certificate SSL for OpenLdap configuration

我在本地使用 LinuxMint 工作,并在 virtualbox 中安装了带有 openldap 的 UbuntuServer。现在我按照本指南进行配置http://help.ubuntu-it.org/12.04/server/serverguide/it/ubuntu-1204-server.pdfTLS/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");
}
?>

但不起作用..

如果我在终端中尝试:

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

它有效!!但是通过PHP为什么?..我尝试在/opt/lampp/etc/openldap 中配置 ldap.conf,但没有结果。

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

    我的 ldap.conf
  1. 在/etc/ldap.conf
  2. 我配置了*TLS_REQCERT允许*
  3. 我必须在同一目录中生成证书的哈希作为符号链接:
ln -s /etc/ssl/certs/192.168.1.46_slapd_cert.pem `openssl x509 -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 创建正确的哈希。