Selenium 测试 HTTPs 信任所有适用于 FF 但不适用于 IE 的证书

发布于 2024-09-16 02:31:59 字数 328 浏览 4 评论 0 原文

我一直在使用 Selenium RC 进行功能测试。

当测试进入我们网站的登录页面并切换到 HTTPS 时,我不断遇到问题。

我不断更改设置,但是每个浏览器都会停止工作。

使用 **iehta* 和 **chrome* 作为我的浏览器以及信任所有 SSL 证书 & 确保干净的会话设置 我可以让 FF3 登录我们的网站,但是 IE 会抛出“此网站的安全证书有问题。” 错误。 (我已经安装了证书)

为什么“信任所有证书”不能与 IE 一起使用?

I've been playing arround with functional testing using Selenium RC.

I keep running into problems when the test goes to the login page of our site and switches to HTTPS.

I keep changing settings but, each browser gets thrown out of working.

Using **iehta* and **chrome* as my browsers and the Trust All SSL Certificates & Ensure Clean Session settings I can get FF3 to login to our site but, IE throws a "There is a problem with this website's security certificate." error. (I have installed the certificate)

Why doesn't Trust All certificates work with IE?

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

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

发布评论

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

评论(6

清眉祭 2024-09-23 02:31:59

有两个步骤。一种是使用“-trustAllSSLCertificates”选项启动服务器,另一种是将浏览器配置为使用 Selenium 服务器作为其代理。 *iexploreproxy 和 *firefoxproxy 为您处理代理设置。如果使用“-trustAllSSLCertificates”标志,Selenium(从 2.0a5 开始)将自动配置 *firefox 以使用 Selenium 服务器作为代理。 *iexplore 使用 HTA,Selenium 从未将其配置为使用代理。因此,您需要先验或通过自定义启动器来处理该问题。

以下文章中有更多详细信息: http://nirvdrum.com/2010/04/13/how-to-accept-self-signed-ssl-certificates-in-selenium.html

There are two steps. One is to start the server with the "-trustAllSSLCertificates" option and the other is to configure the browser to use the Selenium server as its proxy. *iexploreproxy and *firefoxproxy handle the proxy settings for you. Selenium (as of 2.0a5) will auto-configure *firefox to use the Selenium server as a proxy if the "-trustAllSSLCertificates" flag is used. *iexplore, using HTA, is never configured by Selenium to use a proxy. So, you'll need to handle that a priori or via a custom launcher.

More details in the following article: http://nirvdrum.com/2010/04/13/how-to-accept-self-signed-ssl-certificates-in-selenium.html

雅心素梦 2024-09-23 02:31:59

我已设法通过设置 -trustAllSSLCertificates 使其正常工作
并在 FireFox 中创建默认配置文件。

到目前为止,我可以愉快地使用任一浏览器,而不必担心出现不受信任的证书错误。

值得注意的是,我告诉 selenium 使用的浏览器只是 *chrome 和 *iehta。

I have managed to get this to work by setting the -trustAllSSLCertificates
and creating a default profile in FireFox.

So far I can happily use either browser w/o fear of the untrusted certificate errors showing up.

its worth noting that the browsers I tell selenium to use are simply *chrome and *iehta.

热情消退 2024-09-23 02:31:59

我在最新版本的 Selenium RC(即 2.31.0)中没有看到此错误。如果您正在使用:

RemoteControlConfiguration rc= new RemoteControlConfiguration();
    rc.trustAllSSLCertificates();
    SeleniumServer server;
    server=new SeleniumServer(rc);

I have not seen this error with latest version of Selenium RC i.e. 2.31.0. And if you are using:

RemoteControlConfiguration rc= new RemoteControlConfiguration();
    rc.trustAllSSLCertificates();
    SeleniumServer server;
    server=new SeleniumServer(rc);
故事↓在人 2024-09-23 02:31:59

由于某些随机原因,IE 现在看起来很好,所以我坚持按原样配置并尝试对 FF 问题进行排序。

For some random reason IE now seems fine so I stick with the configuration as it is and try and sort the FF problems.

人生百味 2024-09-23 02:31:59

此答案并不直接回答“为什么信任所有证书不能与 IE 一起使用?”,但它确实提供了可能引起此处提出的问题的答案。即对于任何将 Selenium 作为 Windows 服务运行并发现它不信任其自签名证书的人。

问题

IE 不信任自签名机构的根证书和颁发证书,因此会显示一个页面,要求用户决定是否要继续并信任该站点。这会阻止任何硒测试的进行。

解决方案

该解决方案在概念上相对简单且合乎逻辑,根证书和颁发证书必须作为受信任的证书安装在计算机上。

然而,复杂性在于让运行 Selenium RC 的 Windows 服务信任证书(如果该服务在系统帐户下运行)。要纠正此问题,需要执行以下步骤。

  1. 安装根证书作为计算机范围内受信任的证书颁发机构。
  2. 安装颁发证书作为计算机范围的中间证书颁发机构

将证书添加到本地计算机的受信任的根证书颁发机构存储

管理员是完成此过程所需的最低组成员身份。

将证书添加到本地计算机的受信任的根证书颁发机构存储中的

  1. 步骤 单击“开始”,单击“开始搜索”,键入 mmc,然后按 Enter。
  2. 在“文件”菜单上,单击“添加/删除管理单元”。
  3. 在“可用管理单元”下,单击“证书”,然后单击“添加”。
  4. 在“此管理单元将始终管理其证书”下,单击“计算机帐户”,然后单击“下一步”。
  5. 单击“本地计算机”,然后单击“完成”。
  6. 如果没有更多管理单元可添加到控制台,请单击“确定”。
  7. 在控制台树中,双击证书。
  8. 右键单击受信任的根证书颁发机构存储。
  9. 单击“导入”导入证书,然后按照“证书导入向导”中的步骤操作。

将证书添加到本地计算机的中级证书颁发机构存储

  1. 在控制台树中,双击“证书”。
  2. 右键单击中级证书颁发机构存储。
  3. 单击“导入”导入证书,然后按照“证书导入向导”中的步骤操作。

This answer doesn't directly answer "Why doesn't Trust All certificates work with IE?", however it does offer an answer to the question that likely gave rise to the question being asked here. i.e. for anyone running Selenium as a Windows Service and find that it does not trust their self-signed certificates.

The Problem

IE does not trust the root and issuing certificates of a self-signing authority and therefore presents a page requesting the user to decide if he/she wants to continue and trust the site. This prevents any selenium tests progressing.

The Solution

The solution is relatively simple and logical in concept, the root and issuing certificates must be installed on the computer as trusted certs.

However, the complexity lies in getting the Windows Service running Selenium RC to trust the certificates if the service runs under a system account. To rectify this, the following steps are required.

  1. Install the Root certificate as a computer-wide trusted certification authority.
  2. Install the Issuing certificate as a computer-wide intermediate certification authority

Adding certificates to the Trusted Root Certification Authorities store for a local computer

Administrators is the minimum group membership required to complete this procedure.

To add certificates to the Trusted Root Certification Authorities store for a local computer

  1. Click Start, click Start Search, type mmc, and then press ENTER.
  2. On the File menu, click Add/Remove Snap-in.
  3. Under Available snap-ins, click Certificates,and then click Add.
  4. Under This snap-in will always manage certificates for, click Computer account, and then click Next.
  5. Click Local computer, and click Finish.
  6. If you have no more snap-ins to add to the console, click OK.
  7. In the console tree, double-click Certificates.
  8. Right-click the Trusted Root Certification Authorities store.
  9. Click Import to import the certificates and follow the steps in the Certificate Import Wizard.

Adding certificates to the Intermediate Certification Authorities store for a local computer

  1. In the console tree, double-click Certificates.
  2. Right-click the Intermediate Certification Authorities store.
  3. Click Import to import the certificates and follow the steps in the Certificate Import Wizard.
勿忘初心 2024-09-23 02:31:59

IE 将证书错误显示为正常的 html 页面。既然它这样做了,您可以找到该元素并对其执行 .click() 作为临时解决方法。 :) 您只需创建一个证书帮助程序类即可执行此操作并执行 cert.acceptCert(driver);

IE displays the cert error as a normal html page. Since it does that, you can find the element and do a .click() on it as a temporary workaround. :) You can just create a cert helper class to do it and just execute cert.acceptCert(driver);

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文