...
/Connect to a Server with SSL: How to Use the Certificate
Connect to a Server with SSL: How to Use the Certificate
Learn how to connect to a server by importing the server's self-signed certificate.
We'll cover the following...
How to use the certificate
Ignoring a self-signed cert is fine while developing and testing a REST client. However, for the release phase, the application needs to load and validate the certificate sent by the server using it.
The self-signed certs aren’t available in the certs cache/pool of the operating system. Hence, for an application to use them, it needs to do the following:
- Load the cert.
- Pass the cert to the
requests
library so that it can use the cert for validation.
The requests
library loads and passes the cert automatically via the ssl_verify
option. It’s the same ssl_verify
option we used to ignore cert validation in the last lesson.
The service that we’ll use for checking our code will be https://self-signed.badssl.com, as it provides a self-signed certificate for testing purposes. We’ll also need to export the cert of the site to be used in the code.
Note: We’ll reuse and update the code that ...