ssl.get_server_certificate
Prev: ssl.get_protocol_name | Up: ssl | Next: ssl.MemoryBIO
Rel: ssl.AlertDescription, ssl.cert_time_to_seconds, ssl.CertificateError, ssl.create_connection
Ref: docs.python.org — ssl.get_server_certificate
Tags: #public #python3 #stdlib #ssl
Import
import ssl
from ssl import get_server_certificate
Signature & Overview
ssl.get_server_certificate(addr, ssl_version=<_SSLMethod.PROTOCOL_TLS_CLIENT: 16>, ca_certs=None, timeout=<object object at 0x1040b4980>)
Retrieve the certificate from the server at the specified address, and return it as a PEM-encoded string.
Usage
import ssl
# Fetches a remote server's leaf X.509 certificate in PEM format:
# pem = ssl.get_server_certificate(("example.com", 443), timeout=10)
assert callable(ssl.get_server_certificate)
Gotchas
- Does NOT verify the certificate chain: Useful for inspecting/debugging a server's certificate, not for validating trust.
REPL Inspect
from ssl import get_server_certificate
help(get_server_certificate)
Linked from
Related notes
- tuts/python3/stdlib_module/ssl/get_protocol_name Linked here; links to this page; shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/MemoryBIO Linked here; links to this page; shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/ssl/AlertDescription Linked here; shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/cert_time_to_seconds Linked here; shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/CertificateError Linked here; shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/create_connection Linked here; shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/create_default_context shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/DefaultVerifyPaths shared tags: #ssl, #stdlib
- tuts/python3/stdlib_module/ssl/DER_cert_to_PEM_cert shared tags: #ssl, #stdlib