免费注册 查看新帖 |

Chinaunix

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

[ldap] openldap 如何禁止认证客户端 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-04-09 17:10 |只看该作者 |倒序浏览
OS:fedora10
openldap:openldap-servers-2.4.12

openldap启用了ssl

使用openssl测试,在TLSVerifyClient为never时(服务器仍然发送cert request?):
1)客户端提供cert和key,连接失败
[root@localhost cacerts]# openssl s_client -connect mail.f10.com:636 -showcerts -state -CAfile /etc/openldap/cacerts/cacert.pem -ssl3
CONNECTED(00000003)
SSL_connect:before/connect initialization
SSL_connect:SSLv3 write client hello A
SSL_connect:SSLv3 read server hello A
depth=1 /C=zh/ST=bj/O=ft/OU=qa/CN=mail.f10.com/emailAddress=testmail1@mail.f10.com
verify return:1
depth=0 /C=zh/ST=bj/L=bj/O=ft/OU=qa/CN=mail.map.com/emailAddress=wygao@fortinet.com
verify return:1
SSL_connect:SSLv3 read server certificate A
SSL_connect:SSLv3 read server certificate request A
SSL_connect:SSLv3 read server done A
SSL3 alert write:warning:no certificate
SSL_connect:SSLv3 write client certificate A
SSL_connect:SSLv3 write client key exchange A
SSL_connect:SSLv3 write change cipher spec A
SSL_connect:SSLv3 write finished A
SSL_connect:SSLv3 flush data
SSL3 alert read:fatal failure
SSL_connect:failed in SSLv3 read finished A
31861:error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure:s3_pkt.c:1057:SSL alert number 40
31861:error:1409E0E5:SSL routines:SSL3_WRITE_BYTES:ssl handshake failure:s3_pkt.c:534:
2)客户端提供cert和key,连接成功
[root@localhost cacerts]# openssl s_client -connect mail.f10.com:636 -showcerts -state -CAfile /etc/openldap/cacerts/cacert.pem -cert /etc/openldap/cacerts/newcert.pem -key /etc/openldap/cacerts/newkey.pem
Enter pass phrase for /etc/openldap/cacerts/newkey.pem:
CONNECTED(00000003)
SSL_connect:before/connect initialization
SSL_connect:SSLv2/v3 write client hello A
SSL_connect:SSLv3 read server hello A
depth=1 /C=zh/ST=bj/O=ft/OU=qa/CN=mail.f10.com/emailAddress=testmail1@mail.f10.com
verify return:1
depth=0 /C=zh/ST=bj/L=bj/O=ft/OU=qa/CN=mail.map.com/emailAddress=wygao@fortinet.com
verify return:1
SSL_connect:SSLv3 read server certificate A
SSL_connect:SSLv3 read server certificate request A
SSL_connect:SSLv3 read server done A
SSL_connect:SSLv3 write client certificate A
SSL_connect:SSLv3 write client key exchange A
SSL_connect:SSLv3 write certificate verify A
SSL_connect:SSLv3 write change cipher spec A
SSL_connect:SSLv3 write finished A
SSL_connect:SSLv3 flush data
SSL_connect:SSLv3 read finished A
---
Certificate chain
0 s:/C=zh/ST=bj/L=bj/O=ft/OU=qa/CN=mail.map.com/emailAddress=wygao@fortinet.com
   i:/C=zh/ST=bj/O=ft/OU=qa/CN=mail.f10.com/emailAddress=testmail1@mail.f10.com
-----BEGIN CERTIFICATE-----
MIIC3jCCAkegAwIBAgIBAjANBgkqhkiG9w0BAQUFADByMQswCQYDVQQGEwJ6aDEL
MAkGA1UECBMCYmoxCzAJBgNVBAoTAmZ0MQswCQYDVQQLEwJxYTEVMBMGA1UEAxMM
bWFpbC5mMTAuY29tMSUwIwYJKoZIhvcNAQkBFhZ0ZXN0bWFpbDFAbWFpbC5mMTAu
Y29tMB4XDTEwMDMyNDA4MzYwMFoXDTExMDMyNDA4MzYwMFowezELMAkGA1UEBhMC
emgxCzAJBgNVBAgTAmJqMQswCQYDVQQHEwJiajELMAkGA1UEChMCZnQxCzAJBgNV
BAsTAnFhMRUwEwYDVQQDEwxtYWlsLm1hcC5jb20xITAfBgkqhkiG9w0BCQEWEnd5
Z2FvQGZvcnRpbmV0LmNvbTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAtzFc
f90oD4uJeWpdNWAaxmvEeh2Yc/nlYwe0lkyP2a2uvKlSdVMB0GXqw7vtz/qcKdKB
TR4BBNLdOYH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vjx5b+iPVRi
wi9aFGS4LyDwInP0jW0EV/l49ZJ5hu1kKvo4iBZeRdzWQ18DuUeSpbRnpbBhP0jx
+Tau8PoC9A61XuSNMzAUtcOG/bjAoLeWenjffYXxgvXF26R5mi2xm9VmjqK51yng
XdRYeE/g7XE4X8vKja1EK3PDpsMCAwEAAaN7MHkwCQYDVR0TBAIwADAsBglghkgB
hvhCAQ0EHxYdT3BlblNTTCBHZW5lcmF0ZWQgQ2VydGlmaWNhdGUwHQYDVR0OBBYE
FBEfBrylRrKpcwjjtwPiIkwSnIDwMB8GA1UdIwQYMBaAFBEfBrylRrKpcwjjtwPi
IkwSnIDwMA0GCSqGSIb3DQEBBQUAA4GBAF/+I8SD7LrKP+tmWbzbLwG/YDpIH7Jd
P79e4GpkorBxmTw2JHu9tnvcMPMzcuy2Us8o09cBP0bf0aw66Mq0XTXodRFutDkb
JAWWTs4nJOSLFN8YXZub+JOllA8OtGUyhqInjlnoJfRKBR5hxSjScGOdFC+PPUEF
SfpHz2tQwU7u
-----END CERTIFICATE-----
---
Server certificate
subject=/C=zh/ST=bj/L=bj/O=ft/OU=qa/CN=mail.map.com/emailAddress=wygao@fortinet.com
issuer=/C=zh/ST=bj/O=ft/OU=qa/CN=mail.f10.com/emailAddress=testmail1@mail.f10.com
---
Acceptable client certificate CA names
/C=zh/ST=bj/O=ft/OU=qa/CN=mail.f10.com/emailAddress=testmail1@mail.f10.com
---
SSL handshake has read 1759 bytes and written 1964 bytes
---
New, TLSv1/SSLv3, Cipher is AES256-SHA
Server public key is 1024 bit
Compression: NONE
Expansion: NONE
SSL-Session:
    Protocol  : TLSv1
    Cipher    : AES256-SHA
    Session-ID: 6F24B6A9AE1D099DD7E33B87EF8AE7DB7E465001191D2C24CD376C19BE63DDF1
    Session-ID-ctx:
    Master-Key: 0251CCAF2D7B8B0611E7532783BA903523B0C2E29B03192778607A19A3A45C6A0692D29511601B588207C067E5C3090A
    Key-Arg   : None
    Krb5 Principal: None
    Start Time: 1270805146
    Timeout   : 300 (sec)
    Verify return code: 0 (ok)
---


看起来好像是TLSVerifyClient never没有生效,不知道为什么

另问:重启ldap服务不能监听636端口,必须slapd -h "ldap:/// ldaps:///" ,这是为什么?

论坛徽章:
0
2 [报告]
发表于 2010-04-09 17:12 |只看该作者
slapd.conf

#
# See slapd.conf(5) for details on configuration options.
# This file should NOT be world readable.
#

include         /etc/openldap/schema/corba.schema
include         /etc/openldap/schema/core.schema
include         /etc/openldap/schema/cosine.schema
include         /etc/openldap/schema/duaconf.schema
include         /etc/openldap/schema/dyngroup.schema
include         /etc/openldap/schema/inetorgperson.schema
include         /etc/openldap/schema/java.schema
include         /etc/openldap/schema/misc.schema
include         /etc/openldap/schema/nis.schema
include         /etc/openldap/schema/openldap.schema
include         /etc/openldap/schema/ppolicy.schema
include         /etc/openldap/schema/collective.schema

# Allow LDAPv2 client connections.  This is NOT the default.
allow bind_v2
# Do not enable referrals until AFTER you have a working directory
# service AND an understanding of referrals.
#referral       ldap://root.openldap.org

pidfile         /var/run/openldap/slapd.pid
argsfile        /var/run/openldap/slapd.args

loglevel        256

# Load dynamic backend modules:
# modulepath    /usr/lib/openldap # or /usr/lib64/openldap
# moduleload accesslog.la
# moduleload auditlog.la
# moduleload back_sql.la
# moduleload denyop.la
# moduleload dyngroup.la
# moduleload dynlist.la
# moduleload lastmod.la
# moduleload pcache.la
# moduleload ppolicy.la
# moduleload refint.la
# moduleload retcode.la
# moduleload rwm.la
# moduleload syncprov.la
# moduleload translucent.la
# moduleload unique.la
# moduleload valsort.la

# The next three lines allow use of TLS for encrypting connections using a
# dummy test certificate which you can generate by changing to
# /etc/pki/tls/certs, running "make slapd.pem", and fixing permissions on
# slapd.pem so that the ldap user or group can read it.  Your client software
# may balk at self-signed certificates, however.
TLSCipherSuite HIGH:MEDIUM:+SSLv2
TLSCACertificateFile /etc/openldap/cacerts/cacert.pem
TLSCertificateFile /etc/openldap/cacerts/s.cert
TLSCertificateKeyFile /etc/openldap/cacerts/s.key
TLSVerifyClient never
# TLSVerifyClient can be set to try,demand,allow,never
ssl start_tls

# Sample security restrictions
#       Require integrity protection (prevent hijacking)
#       Require 112-bit (3DES or better) encryption for updates
#       Require 63-bit encryption for simple bind
# security ssf=1 update_ssf=112 simple_bind=64

# Sample access control policy:
#       Root DSE: allow anyone to read it
#       Subschema (sub)entry DSE: allow anyone to read it
#       Other DSEs:
#               Allow self write access
#               Allow authenticated users read access
#               Allow anonymous users to authenticate
#       Directives needed to implement policy:
# access to dn.base="" by * read
# access to dn.base="cn=Subschema" by * read
access to *
        by self write
        by users read
        by anonymous read
#
# if no access controls are present, the default policy
# allows anyone and everyone to read anything but restricts
# updates to rootdn.  (e.g., "access to * by * read"
#
# rootdn can always read and write EVERYTHING!

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

database        bdb
suffix          "dc=f10,dc=com"
checkpoint      1024 15
rootdn          "cn=Manager,dc=f10,dc=com"
# Cleartext passwords, especially for the rootdn, should
# be avoided.  See slappasswd( and slapd.conf(5) for details.
# Use of strong authentication encouraged.
# rootpw                secret
rootpw                  111111
# rootpw                {crypt}ijFYNcSNctBYg

# The database directory MUST exist prior to running slapd AND
# should only be accessible by the slapd and slap tools.
# Mode 700 recommended.
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=ldap-1.example.com:389 starttls=critical
#     bindmethod=sasl saslmech=GSSAPI
#     authcId=host/ldap-master.example.com@EXAMPLE.COM


# enable monitoring
database monitor

# allow onlu rootdn to read the monitor
access to attrs=userPassword
        by anonymous write
access to dn="cn=Manager,dc=f10,dc=com"
        by anonymous write


客户端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
#URI ldap://127.0.0.1 ldaps://127.0.0.1:636
#HOST localhost
BASE dc=f10,dc=com

#binddn cn=Manager,dc=f10,dc=com
#bindpw 111111
#ssl star_tls
#ssl on


#URI    ldaps://mail.f10.com ldap://f10.com

tls_cacert /etc/pki/tls/certs/cacert.pem
tls_reqcert demand

#tls_checkpeer yes
#tls_cacertfile /etc/pki/tls/certs/cacert.pem
#TLS_CACERTDIR /etc/pki/tls/certs/cacert.pem
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

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

清除 Cookies - ChinaUnix - Archiver - WAP - TOP