是否有可能使用Selenium和任何浏览器来测试客户端SSL证书? 例如,你可以创建一个网络驱动器,并给假证件呢? 或者使用编写的Firefox配置文件?
Answer 1:
对于SSL客户端证书创建硒Firefox的测试配置文件
你需要准备硒的具有进口客户端证书的webdriver Firefox配置文件。
首先,你推出的webdriver在你的测试代码如下配置:
# Pre-seeded Firefox profile directory
profile_directory = os.path.join(os.path.dirname(__file__), "..", "..", "certs", "firefox-client-ssl-profile")
self.assertTrue(os.path.exists(profile_directory))
profile = FirefoxProfile(profile_directory)
# Make sure the client side certificate selection does not interrupt the test
# XXX: What happens in other language versions?
profile.set_preference("security.default_personal_cert", "Select Automatically")
self.driver = WebDriver(firefox_profile=profile)
self.selenium_helper = SeleniumHelper(self, self.driver)
self.selenium_helper.driver = self.driver
启动单元测试,他们开车到Zope的点测试服务器了。 停止试验用 “进口PDB; pdb.set_trace()”
你现在应该有你的屏幕上的硒的“webdriver的”火狐实例。
导入客户端证书。 首选项>高级>加密>查看证书。 从您的客户端证书导入供应“client.p12”。
访问在URL触发的webdriver的Firefox的客户端证书对话框::
https://yourservevr/triggers-client-side-certificate-ssl-handshake
这应该提示您接受对测试服务器的客户端证书。 手动接受一切。
访问菜单中的帮助>疑难解答信息>应用基础>在Finder中显示。 这将打开临时目录控股的webdriver的活动配置文件。
Firefox的配置文件复制cert8.db
和key3.db
到你的单元测试包的webdriver的Firefox配置文件的种子文件夹。 这是硒精选Firefox网络驱动程序的种子在测试开始的文件夹firefox-client-ssl-profile
。
中断测试。 重新启动测试。 再次运行直至停顿。 在的webdriver的Firefox看到它现在包含了你是在上次运行批准首选项>高级>加密>查看证书证书的设置。
更多信息
https://trac.macports.org/wiki/howto/MAMP
https://support.mozilla.org/en-US/questions/824255
http://wiki.apache.org/httpd/DebuggingSSLProblems#Finding_out_what_caused_a_handshake_to_fail
http://www.openssl.org/docs/apps/s_client.html
https://omni.tenderapp.com/kb/omni-certificate-authorities/importing-pkcs12-certificates-in-keychain-for-safarichrome-in-mac-os-x
http://support.mozilla.org/en-US/kb/Recovering%20important%20data%20from%20an%20old%20profile#w_security-certificate-settings “””
Answer 2:
我不知道这会有所帮助,但你可以在配置文件中改变一些偏好。 在Java中,你可以做到这一点。
ProfilesIni allProfiles = new ProfilesIni();
FirefoxProfile profile = allProfiles.getProfile("default"); //change profile name. there is a note somewhere on how to change it
profile.setPreference(uaKey, uaValue);
profile.setAcceptUntrustedCertificates(acceptUntrustedSsl);
我不知道这是你所需要的。