免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 3172 | 回复: 1
打印 上一主题 下一主题

[ldap] OPenLDAP Master server与Slave server TLS加密问题 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-12-02 14:40 |只看该作者 |倒序浏览
现有多台LINUX服务器,每次给每台机器一一添加帐号都感觉好麻烦,于是就想用LDAP来做这个事情。
现搭建4台虚拟机测试 ldapmaster.example.com 192.168.1.200
                              ldapslave.example.com    192.168.1.201
                              ldapclient-a.example.com 192.168.1.202
                              ldapclient-b.example.com  192.168.1.203
设想ldapmaster.example.com做主认证服务器,ldapslave.example.com做从服务器。当主服务器挂掉时,从服务器能自动替代主服务器工作。
客户端与服务器端之间的传输采用的是TLS加密。
我这样来设置:
1.安装软件

主服务器ldapmaster上安装软件
   
openldap-2.3.43-3.el5
openldap-devel-2.3.43-3.el5
openldap-servers-2.3.43-3.el5
nss_ldap-253-22.el5_4
python-ldap-2.2.0-2.1
openldap-clients-2.3.43-3.el5
openssl-0.9.8e-12.el5

从服务器ldapslave上安装软件

openldap-2.3.43-3.el5
openldap-devel-2.3.43-3.el5
openldap-servers-2.3.43-3.el5
nss_ldap-253-22.el5_4
python-ldap-2.2.0-2.1
openldap-clients-2.3.43-3.el5
openssl-0.9.8e-12.el5

客户端ldapclient-a上安装软件

openldap-2.3.43-3.el5
openldap-devel-2.3.43-3.el5
nss_ldap-253-22.el5_4
python-ldap-2.2.0-2.1
openldap-clients-2.3.43-3.el5
openssl-0.9.8e-12.el5

2.配置主服务器ldapmaster /etc/openldap/slapd.conf

############################################
include                /etc/openldap/schema/core.schema
include                /etc/openldap/schema/cosine.schema
include                /etc/openldap/schema/inetorgperson.schema
include                /etc/openldap/schema/nis.schema
pidfile                /var/run/openldap/slapd.pid
argsfile        /var/run/openldap/slapd.args

#######################################################################
# ldbm and/or bdb database definitions
#######################################################################

database        bdb
suffix                "dc=example,dc=com"
rootdn                "cn=root,dc=example,dc=com"
rootpw {SSHA}CMqHlrrV5RR9bA5icsi/6/7mJNvfVe4k
directory        /var/lib/ldap

# Indices to maintain for this database
index objectClass                       eq,pres
index ou,cn,mail,surname,givenname      eq,pres,sub
index uidNumber,gidNumber,loginShell    eq,pres
index uid,memberUid                     eq,pres,sub
index nisMapName,nisMapEntry            eq,pres,sub

# Replicas of this database
####与从服务器同步部分
replogfile /var/lib/ldap/openldap-master-replog
replica host=ldapslave.example.com:389
        binddn="cn=root,dc=example,dc=com"
        bindmethod=simple
        credentials=secret
        tls=yes

####TLS加密部分
TLSCipherSuite          HIGH:MEDIUM:+SSLv2:+SSLv3:RSA
TLSCACertificateFile    /etc/openldap/cacerts/server.pem
TLSCertificateFile      /etc/openldap/cacerts/server.pem
TLSCertificateKeyFile   /etc/openldap/cacerts/server.pem
TLSVerifyClient         allow
#########################################

3.配置从服务器ldapslave /etc/openldap/slapd.conf

##################################################
include                /etc/openldap/schema/core.schema
include                /etc/openldap/schema/cosine.schema
include                /etc/openldap/schema/inetorgperson.schema
include                /etc/openldap/schema/nis.schema
allow bind_v2
pidfile                /var/run/openldap/slapd.pid
argsfile        /var/run/openldap/slapd.args
#######################################################################
# ldbm and/or bdb database definitions
#######################################################################
database        bdb
suffix                "dc=example,dc=com"
rootdn                "cn=root,dc=example,dc=com"
rootpw {SSHA}CMqHlrrV5RR9bA5icsi/6/7mJNvfVe4k
directory        /var/lib/ldap
index objectClass                       eq,pres
index ou,cn,mail,surname,givenname      eq,pres,sub
index uidNumber,gidNumber,loginShell    eq,pres
index uid,memberUid                     eq,pres,sub
index nisMapName,nisMapEntry            eq,pres,sub

####与主服务器同步部分
updatedn "cn=root,dc=example,dc=com"
updateref ldap://ldapmaster.example.com:389/
####TLS配置部分
TLSCipherSuite          HIGH:MEDIUM:+SSLv2:+SSLv3:RSA
TLSCACertificateFile    /etc/openldap/cacerts/server.pem
TLSCertificateFile      /etc/openldap/cacerts/server.pem
TLSCertificateKeyFile   /etc/openldap/cacerts/server.pem
TLSVerifyClient         allow
############################################

4.配置客户端ldapclient-a  /etc/openldap/ldap.conf
#
# LDAP Defaults
#

# See ldap.conf(5) for details
# This file should be world readable but not world writable.

#BASE        dc=example, dc=com
#URI        ldap://ldap.example.com ldap://ldap-master.example.com:666

#SIZELIMIT        12
#TIMELIMIT        15
#DEREF                never
BASE dc=example,dc=com
URI ldaps://ldapmaster.example.com/  ldaps://ldapslave.example.com/
TLS_CACERTDIR /etc/openldap/cacerts

以上配置用的TLS加密服务器和客户机之间的传输明文信息。现在有一个问题,就是在主服务器ldapmaster创建证书时,server.pem里包含了主服务器域名的信息ldapmaster.example.com,如果是客户机ldapclient-a去同主服务器之间去认证那自然是不会出现问题。如果主服务器DOWN了,从服务器接替主服务器工作的时候,客户机ldapclient-a去从服务器slave去获取认证的时候,由于server.pem里含有的是ldapmaster.example.com的信息,那么自然是通不过认证。
如果不做TLS加密的那也是不存在这样的问题。
我考虑过把ldapmaser.example.com解析成2个IP 192.168.1.200,192.168.1.201,这样就解决了证书的认证问题,但是这样的话,如果其中一台机器DOWN了之后,客户机去服务器认证的时候总会有50%的几率认证失败,这也达不到设置主从服务器认证的初衷。
请大家给点意见。谢谢。

LDAP以及TLS配置参考于 http://www.linuxhomenetworking.c ... ing_LDAP_and_RADIUS
master slave同步配置参考于 http://Linux.chinaitlab.com/administer/519684_

论坛徽章:
0
2 [报告]
发表于 2009-12-12 19:24 |只看该作者
主从服务器各自设置自己的ssl证书(ca证书相同而服务器证书用各自的)即可,因为域名不同,所以ssl用相同的ssl证书是错误的。
客户端的配置已经可以自动切换了。

在多机环境中,推荐使用一个ca来产生各自的认证证书,我推荐用linux下的tinyca。简单实在。

FYI
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP