How to Handle Untrusted Connection in Selenium WebDriver?
You must have come across Untrusted SSL certificate while working on the internet. SSL is used to encrypt confidential information that is sent across the internet, so that it reaches the intended recipient safely.
An Untrusted SSL certificate is a threat, as many of your confidential information like username, password, and credit card numbers could be misused by an intruder. However, web addresses starting with ‘https’ ensures privacy. A trusted SSL certificate helps to validate the authenticity of the website. In case it doesn’t, you will get an error message from your browser. There could be many reasons for the browser to reject a certificate, resulting in an error code. Some of them are discussed below.
This error usually appears when your system shows a wrong date. It can be fixed by setting the system clock to current date.
You will get this error in case of expiration of website identity certification. In addition, incorrect system date could also be the reason. You can fix this by setting the system clock to current date.
The error indicates that the identification received by you is intended for another site.
Depending upon the accessed websites, there could be many more such errors.
Handling SSL Untrusted Connection in Selenium WebDriver
Let’s consider the Firefox browser to create a new profile and set the following:
- ‘setAcceptUntrustedCertificates’: true
- ‘setAssumeUntrustedCertificateIssuer’ : false
//Creating new Firefox profile
FirefoxProfile profile = new FirefoxProfile ();
profile.setAssumeUntrustedCertificateIssuer (false); driver =
new FirefoxDriver (profile); driver.manage ().window ().maximize();
You may also like: Using Selenium WebDriver to Test Carousel Rotation