Method Name
compression
Method Signature
compression()
Return Value
- A python string specifying the compression method used.
- If no compression is used the method returns None.
Overview
- The method compression() returns the compression method used in the secure communication if any.
Example
# Example Python program that retrieves the
# compression level used in the TLS communication
import socket
import ssl
import platform
# Context
ctx = ssl.create_default_context();
ctx.verify_mode = ssl.CERT_REQUIRED
# Check for OS X platform
if platform.system().lower() == 'darwin':
import certifi
import os
# Load CA certificates used for validating the peer's certificate
ctx.load_verify_locations(
cafile=os.path.relpath(certifi.where()),
capath=None,
cadata=None)
# Connect to the server through an instance of an SSLSocket class
skt = socket.socket()
sec_skt = ctx.wrap_socket(skt, server_hostname="example.org")
# Make a connection to the server
sec_skt.connect(("example.com", 443))
comp = sec_skt.compression()
print("Compression used:")
print(comp)Output
Compression used:
None