使用tls/ssl錯誤的問題。
大家好,我配置了使用tls。但總是tls協商失敗。大家幫忙看一下吧。
slapd.conf的配置:
TLSCipherSuite HIGH:MEDIUM:+SSLv2
TLSCACertificateFile /etc/openldap/cacerts/ca.crt.pem
TLSCertificateFile /etc/openldap/server.crt.pem
TLSCertificateKeyFile /etc/openldap/serverkey.pem
TLSVerifyClient never
ssl start_tls
ldap.conf的配置
ssl yes
TLS_CACERTDIR /etc/openldap/cacerts/ca.crt.pem
TLS_REQCERT allow
ssl start_tls
tls_checkpeer yes
tls_cacertdir /etc/openldap/cacerts/ca.crt.pem
使用的證書應該是正確的,但可能的問題是在製作證書輸入Common Name時我使用的是伺服器端的ip(也用過主機名字)。
啟動伺服器的命令行:slapd -h ldaps://:636 -d -1
啟動客戶端的命令行:ldapsearch -H ldaps://:636 -x -b "dc=lenovo,dc=com" -d -1
客戶端提示的錯誤:
TLS certificate verification: Error, self signed certificate
tls_write: want=7, written=7
0000: 15 03 01 00 02 02 30 ......0
TLS trace: SSL3 alert write:fatal:unknown CA
TLS trace: SSL_connect:error in SSLv3 read server certificate B
TLS trace: SSL_connect:error in SSLv3 read server certificate B
TLS: can't connect.
ldap_perror
ldap_bind: Can't contact LDAP server (-1)
additional info: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
《解決方案》
ldap.conf有兩個
/etc/ldap.conf
/etc/openldap/ldap.conf
ldapsearch是用/etc/openldap/ldap.conf的,你如果貼的是下面一個,應該是服務端證書的問題了。
另外fully-qualified distinguished name是你主機完整的域名,比如hostname.example.com,這個是你創建證書的時候需要用到的,沒記錯的話,好像不能用ip或者機器名
《解決方案》
http://www.openldap.org/pub/ksoper/OpenLDAP_TLS.html
看一下官方的說明或許會有幫助~~
弄的時候好像沒感覺這麼複雜~~
《解決方案》
謝謝2摟,上面的文檔我也看了,基本上也參照了那篇文檔,但始終沒能解決
問題。希望指點一下。
《解決方案》
When asked for a 'Common Name', you must enter the fully-qualified distinguished name of the server, e.g. myserver.com, and not 'your name' as is suggested by the OpenSSL prompt. This common mistake is the cause of over 90% of server certificate errors!
這個主意點提到的fully-qualified distinguished name 是什麼呢,我將Common Name設置為伺服器的ip地址或者主機名都沒有成功,用過tls/ssl朋友幫忙解答一下吧。
《解決方案》
把/etc/openldap/ldap.conf的內容貼出來看看
《解決方案》
host 127.0.0.1
base dc=juni,dc=com
port 389
ssl yes
TLS_CACERTDIR /etc/openldap/cacerts/ca.crt.pem
TLS_REQCERT allow
ssl start_tls
tls_checkpeer yes
tls_cacertdir /etc/openldap/cacerts/ca.crt.pem
ldap.conf就是這個樣子,請指點。
《解決方案》
我一直沒關注/etc/openldap/ldap.conf只是更改了/etc/ldap.conf。這個可能是個問題。
還有對於全域名,剛才舉的例子是host.example.com。但是我怎樣確定是什麼呢,確定的只是ip或者主機名。
[ 本帖最後由 hostname 於 2008-7-10 15:50 編輯 ]
《解決方案》
TLS certificate verification: depth: 1, err: 19, subject: /C=US/ST=bj/O=venus/OU=dev/CN=example.com/emailAddress=yyf@example.com, issuer: /C=US/ST=bj/O=venus/OU=dev/CN=example.com/emailAddress=yyf@example.com
TLS certificate verification: Error, self signed certificate in certificate chain
tls_write: want=7, written=7
0000: 15 03 01 00 02 02 30 ......0
TLS trace: SSL3 alert write:fatal:unknown CA
TLS trace: SSL_connect:error in SSLv3 read server certificate B
TLS trace: SSL_connect:error in SSLv3 read server certificate B
TLS: can't connect.
ldap_perror
ldap_bind: Can't contact LDAP server (-1)
additional info: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
現在我的/etc/openldap/ldap.conf的設置為
HOST 127.0.0.1
BASE dc=juni,dc=com
URI ldaps://myserver.com
TLS_CACERT /etc/openldap/cacerts/ca.crt.pem
TLS_REQCERT demand
/etc/openldap/openldap/slapd.conf設置為
TLSCipherSuite HIGH:MEDIUM:+SSLv2
TLSCACertificateFile /etc/openldap/cacerts/ca.crt.pem
TLSCertificateFile /etc/openldap/server.crt.pem
TLSCertificateKeyFile /etc/openldap/serverkey.pem
TLSVerifyClient never
ssl start_tls
在生成證書時,生成ca證書時CN=example.com.生成伺服器證書時 CN=myserver.com。這2個域名都是隨意起的。究竟是什麼原因呢。
《解決方案》
客戶端配置錯誤
如果你要指定ca證書的文件,寫成.....pem
但是如果你要指定ca證書的路徑 路徑中的證書名稱必須是特定的,形式為:xxxx.0
其中,xxxx可以通過openssl命令獲得
好像是 openssl x509 -hash youcert.pem
樓主記得給分。
[ 本帖最後由 forxy 於 2008-7-11 13:01 編輯 ]