将 SSL 证书添加到 Selenium

Adding SSL certificate to Selenium

我正在使用 BrowserMob-Proxy 和 Selenium。加载几乎任何 URL 都会导致浏览器出现 Your connection is not secure, Error code:SEC_ERROR_UNKNOWN_ISSUER 错误。但是,当我导入 certificate given by BMP(通过 Firefox->Options->Advanced->Certificates->Import)时,一切正常。

我的问题是如何以编程方式执行此操作。我已经试过了

profile.accept_untrusted_certs = True

但这似乎根本没有任何影响。有什么办法吗?

创建一个新的 firefox 配置文件"sslProfile"。请参阅 OS.

的 firefox 帮助

在您的硒代码中:

ProfilesIni prof = new ProfilesIni()                
FirefoxProfile foxProfile= prof.getProfile ("sslProfile")

foxProfile.setAcceptUntrustedCertificates(true) 
foxProfile.setAssumeUntrustedCertificateIssuer(false)

WebDriver driver = new FirefoxDriver (foxProfile)