您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

在Firefox和Selenium测试中自动执行SSL客户端证书

在Firefox和Selenium测试中自动执行SSL客户端证书

为SSL客户端证书创建Selenium Firefox测试配置文件

您需要准备Selenium的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测试服务器已启动的位置。使用“ import pdb; pdb.set_trace()”停止测试

现在,您的屏幕上应该有一个Selenium的“ WebDriver” Firefox实例。

导入您的客户端证书。首选项>高级>加密>查看证书。从客户端证书供应中导入“ client.p12”。

在Webdriver的Firefox中访问触发客户端证书对话框的URL ::

    https://yourservevr/triggers-client-side-certificate-ssl-handshake

这应该提示您接受针对测试服务器的客户端证书。手动接受所有内容

访问菜单帮助>故障排除信息>应用程序基础>在Finder中显示。这将打开临时目录,其中包含Webdriver的活动配置文件

将Firefox配置文件复制cert8.db并复制key3.db到您的单元测试包WebDriver的Firefox配置文件的种子文件夹中。测试开始时,Selenium就是在该文件夹中为Firefox Web驱动程序选择种子firefox-client-ssl-profile

中断测试。重新启动测试。运行直到再次暂停。在Webdriver的Firefox中,现在可以在设置中看到它包含您上次运行时批准的证书,这些证书是在“首选项”>“高级”>“加密”>“查看证书”中。

更多信息

https://trac.macports.org/wiki/howto/MAMP

https://support.mozilla.org/zh-CN/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/zh-CN/kb/Recovering%20important%20data%20from%20an%20old%20profile#w_security-certificate-settings “”“

其他 2022/1/1 18:21:06 有471人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶