The feature it's implemented you can see on github project, the thing is that it's not already included in the actual stable release (2.0.0), however it's planned to be included on 2.0.1 release. Meanwhile you can download a 2.0.1 build from here (the link is from git discussion).
I try using 2.0.1
version and I can access to the site correctly passing the SSL client authorization with the follow command:
Finally new PhantomJS 2.1
version was released which includes this feature, you can download from here and test the SSL client authorization using the follow command:
phantomjs --ssl-client-certificate-file=C:mpclientcert.cer
--ssl-client-key-file=C:mpclientcert.key
--ssl-client-key-passphrase=1111
--ignore-ssl-errors=true
C:mpest.js
Notes
I only test this on Windows.
I try to use a PKCS12
file as keystore but seems that with this format doesn't work, so using openssl
I extract the certificate and the private key using the follow commands:
Extract cert for --ssl-client-certificate-file
parameter
openssl pkcs12 -nokeys -clcerts -in a.p12 -out clientcert.cer
Extract key for --ssl-client-key-file
parameter
openssl pkcs12 -nocerts -in a.p12 -out clientcert.key
Additionally I use --ignore-ssl-errors=true
to avoid the configuration of the trust store for the validation of the server certificate.
As script I use test.js which contains the same has OP show on the question:
page = require('webpage').create()
page.open('https://myproject', function(status) {
page.render('C:/temp/connect.png');
console.log(status);
phantom.exit();
})
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…