【发布时间】:2015-02-26 00:13:32
【问题描述】:
我正在尝试请求浏览器以编程方式发送已安装的 p12 证书以进行身份验证。
以下sn-p根据需要生成证书:
$res = \openssl_pkey_new(Config\authentication_key_options());
\openssl_pkey_export($res, $private);
$public = \openssl_pkey_get_details($res);
$public = $pubKey["key"];
# Generate the x509 cert
$csr = \openssl_csr_new(Config\authentication_dn(), $private);
$x509 = \openssl_csr_sign($csr, null, $private, Config\AUTHENTICATION_CERT_VALID_FOR);
# Generate the pcks12
\openssl_pkcs12_export($x509, $p12, $private, null);
然后将生成的证书发送到客户端浏览器进行下载,并将私钥保存在服务器端以供以后使用。
我已将以下内容添加到 apache 的配置中:
SSLVerifyClient optional_no_ca
SSLVerifyDepth 10
SSLOptions +ExportCertData +StdEnvVars
如果没有这样做,我尝试让我的测试脚本发送 401 标头,但无济于事。添加如下 WWW-Authenticate 选项同样不成功:
header("HTTP/1.0 401");
header("WWW-Authenticate: Basic");
header("WWW-Authenticate: transport mode=\"tls-client-certificate\"");
那么我必须添加什么以编程方式(不是通过 apache 的配置静态地)请求浏览器端证书?
【问题讨论】:
标签: php authentication ssl certificate