google-chrome - 客户端证书身份验证不适用于 chrome 和 apache2 服务器
问题描述
我正在尝试使用客户端证书来限制对 apache2 Web 服务器的安全访问。但是,安装后 google chrome 会返回 ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED 错误。
首先,我通过创建 CA 密钥和 X509 PEM 文件为 Web 服务器设置 CA:
openssl genrsa -out CA.key 2048
openssl req -x509 -new -nodes -key CA.key -days 7300 -out CA.pem
我已经有一个在 apache2 中设置的网站的现有证书,用于由受信任的第三方分配的 https 通信。以下是该网站的 apache2 conf 设置,其中我包含了上面生成的证书的 SSLCACertificateFile、SSLOptions、SSLVerifyClient 和 SSLVerfiyDepth 指令:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName site.aname.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/site
<Directory /var/www/html/site>
Options FollowSymLinks
AllowOverride All
Require all granted
SSLOptions +StdEnvVars
SSLVerifyClient require
SSLVerifyDepth 1
</Directory>
LogLevel debug
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLCACertificateFile /etc/apache2/ssl/site/CA.pem
SSLCertificateFile /etc/apache2/ssl/site/fullchain.pem
SSLCertificateKeyFile /etc/apache2/ssl/site/privkey.pem
Include /etc/apache2/ssl/site/options-ssl-apache.conf
</VirtualHost>
</IfModule>
这样就完成了 Web 服务器配置和测试,无需客户端证书并获得预期的错误。
然后我生成一个客户端证书并使用 CA 签名,然后使用以下私钥打包在 pkcs12 中:
产生:
openssl genrsa -out user.key 2028
openssl req -new -key user.key -out user.csr
签署:
openssl x509 -sha256 -req -in user.csr -out user.crt -CA CA.pem -CAkey CA.key -CAcreateserial -days 1095
创建 PKCS12:
openssl pkcs12 -export -out user.pfx -inkey user.key -in user.crt
然后将生成的 user.pfx 安装在运行 chrome 的用户计算机上。
尝试连接时,chrome 会询问选择的密钥,结果是错误 ERR_SSL_CLIENT_AUTH_SIGNATURE_FAILED。
在 Windows 10 下运行的 Chrome 版本为:74.0.3729.169(官方构建)(64 位)
更新:我可以使用来自另一个 linux 服务器的 curl 成功连接:
curl --cert user.crt --key user.key --pass password https://site.aname.com/
但是,与 Windows 10 命令行相同的结果是: curl: (35) schannel: next InitializeSecurityContext failed: Unknown error (0x80090027) - 参数不正确
解决方案
通过确保签名的用户证书是“版本 3”X.509 证书并在 v3 扩展中指定密钥使用和增强的密钥使用属性来解决。这是通过我为 X509 签名请求修改 openssl.conf 文件或使用 openssl CA 命令来实现的。
推荐阅读
- sql - 在查询中并排组合访问 sql 表
- javascript - React:axios.interceptors 不能在 hoc 中工作
- ios - dyld:惰性符号绑定失败:无法解析符号 ___cxa_guard_acquire
- sql - Postgres中相交运算符的问题
- java - 这两个代码有什么区别,为什么会出现错误?
- c# - 在 WM_MOUSEWHEEL 消息中设置 Delta 以使用 PostMessage 发送
- python - 当其他列为空时,将列值与上述行连接
- java - 从http服务器响应资源的正确方法
- aspnetboilerplate - ABP无法连接redis缓存
- javascript - Javascript 不跟踪 DOM 更改