How to Resolve SSL & TSL Certificate in Python
How to Resolve SSL & TSL Certificate in Python
Send download link to:
Have you ever seen below screen before?
All of us have faced this issue while browsing. This happens because the page you are trying to reach is not secure. But how does the browser knows if a page is secure or not? That’s where SSL/TSL Certificate come into picture. But let’s first see what these certificates are.
What is SSL/TSL Certificate?
SSL stands for Secure Sockets Layer and it is the standard technology to keep the connection between a server and browser or two servers secure and protect any sensitive information being exchanged like a password or OTP. This helps in preventing the hackers from stealing important information.
TLS (Transport Layer Security) is an updated version of SSL with more protection. An SSL certificate is installed on the server side but there are visual cues on the browser which can tell users that they are protected by SSL. Firstly, if SSL is present on the site, users will see https:// at the start of the web address rather than the http:// (the extra “s” stand for “secure”)
How SSL Certificates Work?
When a website has a SSL certificate on its server and a browser connects to it the presence of SSL certificate initiate the SSL protocol which encrypts the information sent between the server and browser or two servers.
If a website does not have an SSL certificate then we get the error as shown in first image.
SSL Cert Verification in Request
Requests can verify SSL certificates for HTTPS requests, just like a web browser. To check a host’s SSL certificate, you can use the verify argument. By default it is set as True.
import requests
requests.get('https://github.com', verify=True)
Requests can also ignore verifying the SSL certificate if you set verify to False.
requests.get('https://github.com', verify=False)
But we will see a warning in Jupyter notebook as below:
So it is always advised to set Verify to True. AS it is important for a secure connection and protect your system from a potential attack.
For more about Python request read our Web scraping Python Tutorials.