[SOLVED] CS6262 Project 2 -Network Security, Fall2025

100.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon tls_certificate_grabber-smykzy.zip (2.6 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
🔒 Securely Powered by:
Secure Checkout
5/5 - (2 votes)

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. Write a Python script using pyOpenSSL to fetch certificates from a website served via HTTPS.
  2. You need to complete all of the stubbed functions to get full credit for this question.
  3. Do not remove any functions or classes.
  4. 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.
  5. Make sure the file is named py when uploading it to Gradescope.
  6. 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.
  7. 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.
  8. Choose a recent SSL/TLS version as older versions are deprecated and may not work.
  9. To test your code, you can instantiate your class with various domain names and ports.

 

1.2 Starter Code class TLSCertificateGrabber: # The hostname and port you are connecting to. def __init__(self, hostname, port):

pass

 

# This will be an

<OpenSSL.SSL.Connection object> def connect_and_handshake(self) -> SSL.Connection:

pass

# This will be an <OpenSSL.crypto.X509 object> def get_certificate(self, ssl_sock: SSL.Connection) -> crypto.X509: pass

 

# Format: “YYYYMMDDHHMMSSZ” (ASN.1 GeneralizedTime format) def get_validity_start(self, cert: crypto.X509) -> str:

pass

 

# Format: “YYYYMMDDHHMMSSZ” (ASN.1 GeneralizedTime format) def get_validity_end(self, cert: crypto.X509) -> str:

pass

 

# We only want the issuer’s common name (CN)

# E.g. if the Certificate Authority’s Distinguished Name

# in string format is “/C=US/O=Let’s Encrypt/CN=R3”, # return “R3” def get_certificate_authority(self, cert:

crypto.X509) -> str: pass

 

# Format: a PEM-encoded string, such as

# “—–BEGIN PUBLIC KEY—–\nMIIBIjANBgkh…QIDAQAB\n—–END PUBLIC KEY—–\n” def get_public_key(self, cert: crypto.X509) -> str:

pass

# Ensure the function returns the existing values in # the original order def dump_certificate(self) -> (crypto.X509, str, str, str, str): ssl_sock = self.connect_and_handshake() cert = self.get_certificate(ssl_sock) not_before = self.get_validity_start(cert)

not_after = self.get_validity_end(cert) issuer = self.get_certificate_authority(cert) public_key = self.get_public_key(cert) return cert, issuer, not_before, not_after, public_key

 

# For your own testing if __name__ == “__main__”:

service =

TLSCertificateGrabber(“cs6262.gtisc.gatech.edu”, 443) response = service.dump_certificate() import pprint pprint.pprint(respo nse)

 

1.3 Resources

  1. DigiCert TLS/SSL Certificates Overview
  2. Python 3 socket module documentation
  3. Instructions for installing PyOpenSSL
  4. PyOpenSSL examples

 

  • tls_certificate_grabber-smykzy.zip