0

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

但不起作用..

如果我在终端中尝试:

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

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

4

1 回答 1

1

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

  1. 我的ldap.conf/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 创建正确的哈希值。

于 2014-03-04T20:58:04.967 回答