openldap (2) 配置SSL/TLS加密通信!

知乎连接:

https://zhuanlan.zhihu.com/p/25691864

 

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服务器已经安全!记得实时维护,打补丁.....(没有绝对安全)

转载于:https://my.oschina.net/cson/blog/860346

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值