xxxxxxxxxx
import ssl
import socket
# Set up an SSL context
context = ssl.create_default_context()
# Enable hostname verification
context.check_hostname = True
# Set the server hostname
server_hostname = 'example.com'
# Connect to the server using SSL
with socket.create_connection(('example.com', 443)) as sock:
with context.wrap_socket(sock, server_hostname=server_hostname) as ssl_sock:
# Perform necessary operations with the SSL socket
# ...