问题
Read through all over the internet but still can't resolve the following error while trying to run test script on my test environment
"The certificate is not trusted because the issuer certificate is unknown. The server might not be sending the appropriate intermediate certificates. An additional root certificate may need to be imported."
All software versions are as follows: Firefox - 60.0.2 Python - 3.6 Selenium - 3.12.0 Gecko driver - 20.1
Tried the following and failed: 1- Created custom firefox profile and tried to call in the webdriver code
profile = webdriver.FirefoxProfile("C:/Users/username/AppData/Roaming/Mozilla/Firefox/Profiles/p88ifbjn.Sel")
profile.set_preference('webdriver_assume_untrusted_issuer', True)
profile.update_preferences()
driver = webdriver.Firefox(firefox_profile=profile)
2- Binary code 3 - Accepting un-trusted code 4 - Tried to manually accept certificates
Nothing worked for me, let me know if anyone can help, I am new to automation
回答1:
I search around and couldn't find an working answer either. Interestingly, I found that with updating some already discussed settings, it works in iPython console but not in terminal, for whatever reason. So I went to compare all modified configurations in about:config. There are three preference items that differs. Updating them actually does the magic for me in Mac OS and in Ubuntu. Here is the code. Note you must updating them by changing the default preferences. Code tested in Firefox 63.0.3 with geckodriver version 0.23.0.
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.DEFAULT_PREFERENCES['frozen']['marionette.contentListener'] = True
profile.DEFAULT_PREFERENCES['frozen']['network.stricttransportsecurity.preloadlist'] = False
profile.DEFAULT_PREFERENCES['frozen']['security.cert_pinning.enforcement_level'] = 0
profile.set_preference('webdriver_assume_untrusted_issuer', False)
profile.set_preference("browser.download.folderList", 2)
profile.set_preference("browser.download.manager.showWhenStarting", False)
profile.set_preference("browser.download.dir", temp_folder)
profile.set_preference("browser.helperApps.neverAsk.saveToDisk",
"text/plain, image/png")
driver = webdriver.Firefox(firefox_profile=profile)
来源:https://stackoverflow.com/questions/50780600/python-webdriver-firefox-profiles-error-code-sec-error-unknown-issuer