gpt4 book ai didi

python - 将 SSL 证书添加到 Selenium

转载 作者:太空宇宙 更新时间:2023-11-03 13:15:40 27 4
gpt4 key购买 nike

我正在使用 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”。请参阅适用于您操作系统的 firefox 帮助。

在您的 Selenium 代码中:

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

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

WebDriver driver = new FirefoxDriver (foxProfile)

关于python - 将 SSL 证书添加到 Selenium,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40324931/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com