Created
December 2, 2017 22:12
-
-
Save nabla-c0d3/4d08bf2cdebfef2b75aea493eab09817 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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