在 Firefox 中添加安全例外

发布于 2024-10-31 06:05:24 字数 196 浏览 2 评论 0原文

我有一个运行 watir-webdriver(使用 Firefox 4.0)的脚本,需要访问 Firefox 认为具有无效证书的网页。

问题是,在我接受证书后,Firefox 会直接返回同一页面,就好像我从未接受过它一样。

仅当 Firefox 从 watir-webdriver 启动时才会出现这种情况。如果我手动启动它,它将正确接受安全异常。

I have a script running watir-webdriver(using Firefox 4.0) that needs to access a web page that Firefox thinks has an invalid certificate.

The problem is that after I accept the certificate, Firefox just goes right back to the same page as if I never accepted it.

This only occurs if Firefox was started from watir-webdriver. If I start it manually, it will properly accept the security exception.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

姐不稀罕 2024-11-07 06:05:24

Firefox 驱动程序为每个实例创建一个新的匿名配置文件,因此它可以在您的默认配置文件中工作,但不能与 WebDriver 一起工作,这并不奇怪。

WebDriver 通常非常擅长处理证书问题,但有一个边缘情况:您提供的有效证书与所提供的主机名不匹配(例如测试环境中的生产证书)。如果是这种情况,您需要在 Firefox 配置文件中设置一个标志:

profile = Selenium::WebDriver::Firefox::Profile.new
profile.assume_untrusted_certificate_issuer = false

browser = Watir::Browser.new(:firefox, :profile => profile)

如果这没有帮助,您也可以仅使用默认配置文件作为模型:

browser = Watir::Browser.new(:firefox, :profile => "default")

The Firefox driver creates a new anonymous profile for each instance, so that it's working in your default profile but not with WebDriver isn't that suprising.

WebDriver is usually pretty good at dealing with certificate issues, but there is an edge case: you're serving a valid certificate that doesn't match the host name it's served from (e.g. production certificates in a test environment). If that's the case, you'll want to set a flag in the Firefox profile:

profile = Selenium::WebDriver::Firefox::Profile.new
profile.assume_untrusted_certificate_issuer = false

browser = Watir::Browser.new(:firefox, :profile => profile)

If that doesn't help, you can also just use your default profile as a model:

browser = Watir::Browser.new(:firefox, :profile => "default")
空心空情空意 2024-11-07 06:05:24

您是否尝试过转到“工具”->“选项”->-“高级”->“加密”选项卡
然后单击验证按钮并取消选中使用在线证书状态协议 (OCSP) ...

您可以使用 Selenium 的 Ruby 绑定以编程方式禁用此功能
例如

require 'selenium-webdriver'
require 'watir-webdriver'
profile = Selenium::WebDriver::Firefox::Profile.new
profile["security.OCSP.enabled"] = 0
driver = Selenium::WebDriver.for :firefox, :profile => profile
browser = Watir::Browser.new(driver)

Have your tried going to Tools->Options->-Advanced->Encryption Tab
Then click the Validation button and uncheck use the Online Certificate Status Protocol (OCSP) ...

You can disable this programatically with the Ruby bindings for Selenium
e.g.

require 'selenium-webdriver'
require 'watir-webdriver'
profile = Selenium::WebDriver::Firefox::Profile.new
profile["security.OCSP.enabled"] = 0
driver = Selenium::WebDriver.for :firefox, :profile => profile
browser = Watir::Browser.new(driver)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文