Method Name:
load_cert_chain
Method Signature:
load_cert_chain(certfile, keyfile=None, password=None)
Parameters:
certfile - Path of the X.509 certificate file in PEM(Privacy Enhanced Email) format.
keyfile - The private key of the certificate
password - Password for the private key if the private key is encrypted. The value to this parameter can be a str, bytes or bytearray or a function returning str, bytes or bytearray.
Return value:
None
Overview:
- The method load_cert_chain() loads an X.509 certificate and its private key into the SSLContext object.
- The loaded certificate will be used during the TLS/SSL handshake with the peer.
Example:
This SSL Client program can be used along with the SSL Server program provided in the Introduction to the SSLSocket in Python.
| # Example Python program that uses SSLContext.load_cert_chain() # Server IP and Port details # Construction of an SSLContext # Loading of CA certificate. # Ease the policy of Python3.13 towards self-signed certificates # Loading of client certificate # Create a stream based client socket # Make the client socket suitable for secure communication # Obtain the certificate from the server print("The server certificate is not valid after:") | 
Output:
| The server certificate is not valid before: |