将ssl证书提供给phantomjs的正确方法是什么?

Joh*_*all 9 ssl phantomjs

我需要访问通过客户端证书保护的内部站点.因此,为了使用phantomjs,我导出了我在Firefox中使用的证书来访问该站点,并使用openssl命令行将其转换为私钥和证书.我现在是什么phantomjs在访问服务器上的页面时将该证书呈现给ssl服务器.我该怎么做?

我试过这个

phantomjs --ssl-certificates-path=/etc/pki  --ignore-ssl-errors=yes --proxy=myproxy:myport test.js
Run Code Online (Sandbox Code Playgroud)

/ etc/pki是我放置证书和密钥的路径

test.js就是这个; -

page = require('webpage').create()
page.open('https://myprotectedsite/', function(status) {
console.log(status);
phantom.exit();
})
Run Code Online (Sandbox Code Playgroud)

但它不起作用.console.log(status)总是'失败'

我需要做什么?

alb*_*iff 11

你可以在github项目中看到它实现的功能,事实是它还没有包含在实际的稳定版本(2.0.0)中,但它计划包含在2.0.1版本中.同时你可以从这里下载2.0.1版本(链接来自git讨论).

我尝试使用2.0.1版本,我可以通过以下命令正确访问网站传递SSL客户端授权:

最后PhantomJS 2.1发布了包含此功能的新版本,您可以从此处下载并使用以下命令测试SSL客户端授权:

phantomjs --ssl-client-certificate-file=C:\tmp\clientcert.cer 
          --ssl-client-key-file=C:\tmp\clientcert.key 
          --ssl-client-key-passphrase=1111 
          --ignore-ssl-errors=true 
          C:\tmp\test.js
Run Code Online (Sandbox Code Playgroud)

笔记

我只在Windows上测试它.

我尝试使用一个PKCS12文件作为密钥库,但似乎这种格式不起作用,所以使用openssl我使用以下命令提取证书和私钥:

提取--ssl-client-certificate-file参数的证书

openssl pkcs12 -nokeys -clcerts -in a.p12 -out clientcert.cer
Run Code Online (Sandbox Code Playgroud)

提取--ssl-client-key-file参数的键

openssl pkcs12 -nocerts -in a.p12 -out clientcert.key
Run Code Online (Sandbox Code Playgroud)

另外,我使用--ignore-ssl-errors=true避免配置信任存储区来验证服务器证书.

作为脚本我使用test.js包含相同的OP显示问题:

page = require('webpage').create()
page.open('https://myproject', function(status) {
      page.render('C:/temp/connect.png');
      console.log(status);
      phantom.exit();
})
Run Code Online (Sandbox Code Playgroud)


ste*_*dox 5

自最初接受的答案以来,实际上已经实施了客户端证书支持.我发布这个是为了帮助那些偶然发现这个问题的人.您可以在PhantomJS的CLI说明中找到用于启用X509/PKI证书支持的参数:

phantomjs --ssl-certificates-path=/path/to/pki/rootCA.pem
          --ssl-client-certificate-file=/path/to/pki/cert.pem
          --ssl-client-key-file=/path/to/pki/cert.np.key
Run Code Online (Sandbox Code Playgroud)


小智 4

我也在寻找决定。它没有实现 https://github.com/ariya/phantomjs/issues/10524

“--ssl-certificates-path” - 用于 CA 证书