栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

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

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

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

您需要准备Selenium的WebDriver Firefox配置文件,其中已导入了客户端证书。

首先,在测试代码中使用以下配置启动WebDriver:

# Pre-seeded Firefox profile directoryprofile_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 “”“



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/636054.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号