PowerWebShot icon indicating copy to clipboard operation
PowerWebShot copied to clipboard

Failure to Screenshot Servers With SSL Certificate Issues

Open dafthack opened this issue 8 years ago • 0 comments

Currently, PowerWebShot fails to screenshot web servers with SSL issues such as self-signed certificates, or invalid certificates. I believe this is due to the "acceptSslCerts" flag being set to 'false' by PhantomJS. I've tried a number of different options for accepting SSL certs but none seem to be working.

I've tried the following:

  • Passing CLI Args to phantomjs.exe including --ignore-ssl-errors=yes
  • Setting DesiredCapabilities prior to creating the PhantomJS object including ('CapabilityType.ACCEPT_SSL_CERTS', $true)
  • Adding additional capabilities after creating the PhantomJS object.

Adding additional capabilities to a PhantomJSOptions object prior to creating the PhantomJS object appears to set some options correctly but not "acceptSslCerts". For example, in the current code setting ("phantomjs.page.settings.webSecurityEnabled", $false) does actually set that option to false. However trying a number of variations on ignore-ssl-errors doesn't seem to work.

Current Relevant Code:

$SeleniumDriverPath = ".\WebDriver.dll"
Add-Type -path $SeleniumDriverPath
[OpenQA.Selenium.PhantomJS.PhantomJSOptions]$options = New-Object OpenQA.Selenium.PhantomJS.PhantomJSOptions
#$caps = [OpenQA.Selenium.Remote.DesiredCapabilities]::phantomjs()
#$caps.SetCapability('CapabilityType.ACCEPT_SSL_CERTS', $true)
$cli_args = @()
$cli_args +=  "--web-security=no"
$cli_args += "--ignore-ssl-errors=yes"
$options.AddAdditionalCapability("phantomjs.cli.args", $cli_args)
$options.AddAdditionalCapability("phantomjs.page.settings.ignore-ssl-errors", $true)
$options.AddAdditionalCapability("phantomjs.page.settings.webSecurityEnabled", $false)
$options.AddAdditionalCapability("phantomjs.page.settings.userAgent", "Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko")
$phantomjspath = ".\"
$driver = New-Object OpenQA.Selenium.PhantomJS.PhantomJSDriver($phantomjspath, $options)
#$driver = New-Object OpenQA.Selenium.Remote.RemoteWebDriver($uri,$caps)

dafthack avatar Apr 19 '17 14:04 dafthack