1 TLS Certificates (2 Points)
Certificates are used to bind a domain name (e.g. https://google.com) to an entity (Google, the company). A certificate authority (CA) is a trusted third-party that verifies that an entity controls access to its website. When you access a website on a browser, your browser checks for a valid TLS certificate. If one is unavailable or expired, it informs users that the connection is not safe. In this assignment, you will implement a part of this functionality.
1.1 Notes
1. Download the template provided on Canvas.
2. Write a Python script using pyOpenSSL to fetch certificates from a website served via HTTPS.
3. You need to complete all of the stubbed functions to get full credit for this question.
4. Do not remove any functions or classes.
5. Use pyOpenSSLand built-in socket module to connect to a server, perform a TLS handshake, retrieve the certificate and extract information such as the start and end dates of the validity period, the common name of the certificate issuer, and public key. You do not need any other libraries.
6. Make sure the file is named tls_certificate_grabber.py when uploading it to Gradescope.
7. When doing handshakes with your TLS context manager, ensure you set the server domain, because some websites use Server Name Indication to provide different certificates based on the domain.
8. Do not hard code inputs to any function (unless it only accepts one of a few different constants), and ensure your TLS Certificate Grabber can work with any website.
9. Choose a recent SSL/TLS version as older versions are deprecated and may not work.
10. To test your code, you can instantiate your class with various domain names and ports.
1.2 Resources
1. DigiCert TLS/SSL Certificates Overview
2. Python 3 socket module documentation
3. Instructions for installing PyOpenSSL








