openldap(2)配置SSL/TLS加密通信![通俗易懂]

(117) 2023-07-03 19:12

Hi,大家好,我是编程小6,很荣幸遇见你,我把这些年在开发过程中遇到的问题或想法写出来,今天说一说openldap(2)配置SSL/TLS加密通信![通俗易懂],希望能够帮助你!!!。

openldap(2)配置SSL/TLS加密通信![通俗易懂]_https://bianchenghao6.com/blog__第1张

OpenLDAP

1,ldap服务器自制签名&证书

ldap服务器安装ldap:yum install -y openldap openldap-servers openldap-clients migrationtools openssl

#cd /etc/openldap/certs/

# openssl genrsa -out ldap.key 1024 //私钥

# openssl req -new -key ldap.key -out ldap.csr //生成签名请求

# openssl x509 -req -days 1095 -in ldap.csr -signkey ldap.key -out ldap.crt //公钥 自签名

###########ldap.key(私钥)、ldap.crt(证书、公钥)############

2,返回上级目录,对cert设置权限:

# chmod 700 certs/

# chown -R ldap.ldap certs/

3,修改ldap服务器配置文件 /etc/openldap/certs/ldap.conf 、 /etc/openldap/certs/sldap.conf文件。

# vim /etc/openldap/ldap.conf

TLS_CACERTDIR /etc/openldap/certs

TLS_REQCERT allow

URI ldaps://http://xxx.xxx.xxx.xxx ###配置URI

BASE dc=xxx,dc=xxxx ###设置为ldap的域名

##################################

# vim /etc/openldap/slapd.conf

TLSCACertificatePath /etc/openldap/certs

TLSCertificateFile /etc/openldap/certs/ldap.crt

TLSCertificateKeyFile /etc/openldap/certs/ldap.key

4,修改本地ldap系统配置,开启ldaps

#vim /etc/sysconfig/ldap

SLAPD_LDAP=no ######根据自己需要进行配置,这里关掉

SLAPD_LDAPI=no ######根据自己需要进行配置,这里关掉

SLAPD_LDAPS=yes

5,服务器启动服务&配置自启动

# service slapd stop #先关闭

rm -rf /etc/openldap/slapd.d/* ##第一次安装时需要执行这个步骤,如果ldap服务已经配置好,只是更改ldap协议为ldaps协议,不需要执行此步骤。

# slaptest -f /etc/openldap/slapd.conf -F /etc/openldap/slapd.d/

# chown -R ldap.ldap /etc/openldap/slapd.d/

# service slapd start #开启

配置自启动:

#chkconfig slapd on

6,客户端配置及测试

客户端机器安装openldap-clients openldap

更改客户端配置文件

# vim /etc/openldap/ldap.conf

TLS_CACERTDIR /etc/openldap/certs

TLS_REQCERT allow

URI ldaps://http://xxx.xxx.xxx.xxx ###配置URI

BASE dc=xxx,dc=xxxx ###设置为ldap的域名

##################################

测试:

#ldapsearch -x -W -D "cn=Manager,dc=test,dc=com" -b "dc=test,dc=com" - H ldaps://xxxxxx

输入密码,ok!

打完收工!!

自此ldap服务器已经安全!记得实时维护,打补丁.....(没有绝对安全)

上一篇

已是最后文章

下一篇

已是最新文章

发表回复