如何让 Apache 信任使用未知 CA 的客户端证书,而不验证 CA

Mau*_*ari 5 ssl certificate ssl-certificate certificate-authority apache-2.4

我处于以下情况。我需要设置与外部系统的双向集成。外部系统的管理员要求我发送两个 CSR,一个用于生成客户端证书,另一个用于生成服务器证书。他们寄给我相应的证书。我设置了通道 me-> they 成功(即:我可以调用他们的服务提供我的客户端证书),但我无法正确设置反向通道(即:我无法让我的 Apache 接受他们的客户端证书没有抱怨)。

连同我的服务器证书(我们称之为 my-server.pem),他们还向我发送了他们自己的客户端证书(我们称之为 their-client.pem)。该证书(他们的客户端.pem)由“自签名”CA 发出,该 CA 不在我的 Linux 系统中已经可用的那些知名 CA 中。我没有这个证书,我还不能从外部系统管理员那里得到它(他们不情愿...让我们搁置对此的任何评论...>-|)

这是我在 Apache 中设置 VirtualHost 的方式:

SSLEngine on
SSLCertificateFile /path/to/my-server.pem
SSLCertificateKeyFile /path/to/my-server-secret-key.key
SSLVerifyClient require
SSLCACertificateFile /path/to/their-client.pem
SSLVerifyDepth 0
Run Code Online (Sandbox Code Playgroud)

由于我没有 CA 证书,而且我完全可以说“只相信该客户端证书,没有其他人!”,我将客户端证书本身作为SSLCACertificateFile,如以下答案中所建议的: https:// security.stackexchange.com/questions/36069/use-client-certificate-using-self-signed-ca-while-using-web-certificate-of-a-pub

但是,这似乎不起作用。他们看到的错误是:

javax.net.ssl.SSLException: Received fatal alert: unknown_ca
Run Code Online (Sandbox Code Playgroud)

启用 SSL 日志并将其设置为调试后,我看到的是:

[ssl:debug] [pid 3396] ssl_engine_kernel.c(1381): [client <their-ip>:41474] AH02275: Certificate Verification, depth 1, CRL checking mode: none [subject: CN=Test CA,OU=Foo,O=Bar,C=it / issuer: CN=Test CA,OU=Foo,O=Bar,C=it / serial: 1BFE / notbefore: Dec  6 15:22:45 2010 GMT / notafter: Dec  6 15:21:52 2020 GMT]
[ssl:info] [pid 3396] [client <their-IP>:41474] AH02276: Certificate Verification: Error (19): self signed certificate in certificate chain [subject: CN=Test CA,OU=Foo,O=Bar,C=it / issuer: CN=Test CA,OU=Foo,O=Bar,C=it / serial: 1BFE / notbefore: Dec  6 15:22:45 2010 GMT / notafter: Dec  6 15:21:52 2020 GMT]
[ssl:info] [pid 3396] [client <their-IP>:41474] AH02008: SSL library error 1 in handshake (server my-server.com:443)
[ssl:info] [pid 3396] SSL Library Error: error:140890B2:SSL routines:SSL3_GET_CLIENT_CERTIFICATE:no certificate returned
[ssl:info] [pid 3396] [client <their-IP>:41474] AH01998: Connection closed to child 54 with abortive shutdown (server my-server.com:443)
Run Code Online (Sandbox Code Playgroud)

换句话说,它仍在尝试验证客户端证书的虚拟 CA。我也尝试更改SSLVerifyDepth为 1,但没有运气(同样的错误)。如果我禁用客户端证书请求(通过更改SSLVerifyClient值),调用会正常进行,但我认为这不是正确的方法。

一个非常相似的问题是: 如何让 apache 请求客户端 SSL 证书而无需针对已知 CA 进行验证?

但是,我不确定我是否理解已接受的解决方案。首先,我必须验证的客户端证书不是自签名的(它由未知的 CA 颁发)。

其次,从我从 Apache/mod_ssl 文档中了解到,SSLVerifyCLient optional_no_ca实际上禁用了强客户端证书身份验证,因为它使其成为可选的。

第三,创建与丢失的根 CA 证书具有相同 DN 的假证书的可能性听起来像是强制客户端发送其客户端证书的解决方法,但在我的情况下,我不认为我的问题是客户端没有发送我证书,而是 Apache 无法完全正确验证它。

关于这个主题的任何建议都会非常有帮助。

Civ*_*dan 0

我不是 Apache 专家,但从证书的角度来看,如果他们不想向您提供其根 CA 的公钥,只需要求他们从知名 CA 而不是他们自己的 CA 获取客户端证书。例如,StartSSL 提供免费的 1 年证书。你正在制造一场噩梦,因为合作伙伴不明白它是如何运作的。另一种方法是安装您自己的 CA (Linux) https://jamielinux.com/docs/openssl-certificate-authority/ (Windows) http://datacenteroverlords.com/2012/03/01/creating-your-own- ssl-certificate-authority/并要求他们向您提供要替换的 CSR (their-client.pem)