我正在设置 Apache 以进行智能卡身份验证。智能卡登录基于由操作系统驱动程序处理的客户端 SSL 证书。
我目前只有一个智能卡提供商,但将来可能会有多个。我不确定 Apache 2.2 如何处理每个位置的客户端认证。我做了一些快速测试,似乎只有最后一个 SSLCACertificateFile 指令有效,这听起来不对。
Apache(2.2、2.4)中每个位置是否可以有不同的 SSLCACertificateFile (如下所述)或者 SSL 协议是否以某种方式限制每个 IP 不能有多个 SSLCACertificateFile?
下面的示例潜在配置说明了我希望如何在同一服务器上处理多个 SSLCACertificateFile,以允许用户使用不同的智能卡登录。
<VirtualHost 127.0.0.1:443>
# Real men use mod_proxy
DocumentRoot "/nowhere"
ServerName local-apache
ServerAdmin [email protected]
SSLEngine on
SSLOptions +StdEnvVars +ExportCertData
# Server-side HTTPS configuration
SSLCertificateFile /etc/apache2/certificate-test/server.crt
SSLCertificateKeyFile /etc/apache2/certificate-test/server.key
# Normal SSL site traffic does not require verify client
SSLVerifyClient none
SSLVerifyDepth 999
# Provider 1
<Location /@@smartcard-login>
SSLVerifyClient require
SSLCACertificateFile /etc/apache2/certificate-test/ca.crt
# Apache does not natively pass forward headers
# created by SSLOptions +StdEnvVars,
# so we pass them forward to Python using RequestHeader
# from mod_headers
RequestHeader set X-Client-DN %{SSL_CLIENT_S_DN}e
RequestHeader set X-Client-Verify %{SSL_CLIENT_VERIFY}e
</Location>
# Provider 2
<Location /@@smartcard-login-provider-2>
# For real
SSLVerifyClient require
SSLCACertificateFile /etc/apache2/certificate-test/provider2.crt
# Apache does not natively pass forward headers
# created by SSLOptions +StdEnvVars,
# so we pass them forward to Python using RequestHeader
# from mod_headers
RequestHeader set X-Client-DN %{SSL_CLIENT_S_DN}e
RequestHeader set X-Client-Verify %{SSL_CLIENT_VERIFY}e
</Location>
# Connect to Plone ZEO client1 running on fg
ProxyPass / http://localhost:8080/VirtualHostBase/https/local-apache:443/folder_sits/sitsngta/VirtualHostRoot/
ProxyPassReverse / http://localhost:8080/VirtualHostBase/https/local-apache:443/folder_sits/sitsngta/VirtualHostRoot/
</VirtualHost>
答案1
正如 Vlastimil Zima 所回答的,您确实可以SSLRequire
这样做(至少如果您想要/需要在两个 CA 之间做出区分的话)。否则,只需将两个证书合并为一个就足够了(正如 Curtis 所问的:是的,您可以合并证书来实现这样的功能)。并且看到您的示例,只需合并就足够了。
您可以使用来SSLRequire
检查发行者(假设 CN 不同),例如:
<Location /locationone>
SSLRequire %{SSL_CLIENT_I_DN_CN} == "THE CN OF THE FIRST ISSUER"
</location>
<Location /locationtwo>
SSLRequire %{SSL_CLIENT_I_DN_CN} == "THE CN OF THE SECOND ISSUER"
</location>
为了使其正常工作,您仍然需要将 2 个 CA 证书合并为一个。
答案2
指令SSLCACertificateFile
具有虚拟主机上下文,因此即使插入也会影响整个虚拟主机Location
。您需要使用来SSLRequire
检查客户端是否为位置使用了正确的证书。
http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslrequire