我已经使用openssl生成了一个证书,并将其放置在客户端的机器上,但是当我尝试使用该证书连接到我的服务器时,我在服务器的主题行中提到了错误。
这是我所做的。
1)我使用openssl进行testing连接,看看可接受的客户端证书CA名称是为我的服务器,我从我的客户端机器发出此命令到我的服务器:
openssl s_client -connect myupload.mysite.net:443/cgi-bin/posupload.cgi -prexit
我回来的部分是:
Acceptable client certificate CA names /C=US/ST=Colorado/L=England/O=Inteliware/OU=Denver Office/CN=Tim Drake/[email protected] /C=US/ST=Colorado/O=Inteliware/OU=Denver Office/CN=myupload.mysite.net/[email protected]
2)以下是服务器上关于SSL客户端authentication的apacheconfiguration文件中的内容:
SSLCACertificatePath /etc/apache2/certs SSLVerifyClient require SSLVerifyDepth 10
3)我使用mypos.pem和mypos.key生成了一个名为“client.pem”的自签名客户端证书,所以当我运行这个命令时:
openssl x509 -in client.pem -noout -issuer -subject -serial
这里是返回的内容:
issuer= /C=US/ST=Colorado/O=Inteliware/OU=Denver Office/CN=myupload.mysite.net/[email protected] subject= /C=US/ST=Colorado/O=Inteliware/OU=Denver Office/CN=mlR::mlR/[email protected] serial=0E
(请注意,mypos.pem位于/ etc / apache2 / certs /中,而mypos.key保存在/ etc / apache2 / certs / private /中)
4)我把client.pem放在客户机上,在客户机上运行下面的命令:
openssl s_client -connect myupload.mysite.net:443/cgi-bin/posupload.cgi -status -cert client.pem
我得到这个错误:
CONNECTED(00000003) OCSP response: no response sent depth=1 /C=US/ST=Colorado/L=England/O=Inteliware/OU=Denver Office/CN=Tim Drake/[email protected] verify error:num=19:self signed certificate in certificate chain verify return:0 574:error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca:/SourceCache/OpenSSL098/OpenSSL098-47/src/ssl/s3_pkt.c:1102:SSL alert number 48 574:error:140790E5:SSL routines:SSL23_WRITE:ssl handshake failure:/SourceCache/OpenSSL098/OpenSSL098-47/src/ssl/s23_lib.c:182:
我真的被困在我做错了什么。 我已经search了很多这个错误,我发现的是,人们说客户端证书的颁发CA不受服务器的信任,但是当我查看我的客户端证书的颁发者时,它匹配其中的一个由我的服务器返回的接受的CA.
任何人都可以帮忙吗?
先谢谢你。
好的,我终于发现问题是什么,并希望分享它,以防万一任何人也卡住了这个错误信息。
谈到CA时,Apache的configuration文件有以下几行:
# Set the CA certificate verification path where to find CA # certificates for client authentication or alternatively one # huge file containing all of them (file must be PEM encoded) # Note: Inside SSLCACertificatePath you need hash symlinks # to point to the certificate files. Use the provided # Makefile to update the hash symlinks after changes.
这意味着SSLCACertificatePath指向的此目录中的每个证书文件都必须使用符号链接。 而且,最重要的是,每个符号链接的名称必须是每个证书的主题哈希值。 您可以运行以下命令来查找CA证书的哈希值:
openssl x509 -subject_hash -in *cacert.pem*
因此,如果散列值为0434423b,则在SSLCACertificatePath指向的目录中,应该创build两个符号链接来指向目录中的证书:
0434423b -> /etc/apache2/certs/mypos.pem 0434423b.0 -> /etc/apache2/certs/mypos.pem
这应该解决这个问题。 当然,如果我使用了SSLCACertificateFile,我不认为我遇到过这么多问题。
我在这里find了SSLCACertificatePath的解释:
openssl的validation命令页面
查看-CApath目录下
我发现“sudo update-ca-certificates -fresh”命令会自动生成从每个证书的主题哈希值到证书的符号链接。
嗨你有没有试过运行下面的命令,
openssl s_client -connect myupload.mysite.net:443/cgi-bin/posupload.cgi -status -cert client.pem -verify 1 -showcerts
注意validation1 。 它告诉ssl需要多深,我认为这可能是你在Apacheconfiguration中遇到的问题。 尝试设置Apacheconfiguration,
SSLVerifyDepth 1
干杯,德克斯特