Skip to content

Instantly share code, notes, and snippets.

@nabla-c0d3
Created December 2, 2017 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nabla-c0d3/4d08bf2cdebfef2b75aea493eab09817 to your computer and use it in GitHub Desktop.
Save nabla-c0d3/4d08bf2cdebfef2b75aea493eab09817 to your computer and use it in GitHub Desktop.
from pympler import tracker
from sslyze.server_connectivity import ServerConnectivityInfo, ServerConnectivityError
from sslyze.ssl_settings import TlsWrappedProtocolEnum
memory_tracker = tracker.SummaryTracker()
# Setup the server to scan and ensure it is online/reachable
hostname = 'smtp.gmail.com'
for i in range(20):
try:
server_info = ServerConnectivityInfo(hostname=hostname, port=587,
tls_wrapped_protocol=TlsWrappedProtocolEnum.STARTTLS_SMTP)
server_info.test_connectivity_to_server()
client = server_info.get_preconfigured_ssl_connection()
memory_tracker.print_diff()
except ServerConnectivityError as e:
# Could not establish an SSL connection to the server
raise RuntimeError('Error when connecting to {}: {}'.format(hostname, e.error_msg))
memory_tracker.print_diff()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment