Skip to content

Instantly share code, notes, and snippets.

@nabla-c0d3
Last active March 4, 2018 18:58
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/91d6544018e75efe4385b2f4409854ab to your computer and use it in GitHub Desktop.
Save nabla-c0d3/91d6544018e75efe4385b2f4409854ab to your computer and use it in GitHub Desktop.
Migrating to SSLyze 1.4.0
# With SSLyze 1.4.0, the code that performs connectivity testing with a server needs to be slightly changed:
# SSLyze before 1.4.0
try:
server_info = ServerConnectivityInfo(
hostname='smtp.gmail.com',
port=587,
tls_wrapped_protocol=TlsWrappedProtocolEnum.STARTTLS_SMTP
)
server_info.test_connectivity_to_server()
except ServerConnectivityError as e:
raise RuntimeError('Error when connecting: {}'.format(e.error_msg))
# Then run scan commands using server_info...
# SSLyze 1.4.0+
try:
# The class to do connectivity testing is now distinct from ServerConnectivityInfo
server_tester = ServerConnectivityTester(
hostname='smtp.gmail.com',
port=587,
tls_wrapped_protocol=TlsWrappedProtocolEnum.STARTTLS_SMTP
)
# But the result of connecitivty testing is a ServerConnectivityInfo
server_info = server_tester.perform()
except ServerConnectivityError as e:
# ServerConnectivityError now contains information about the server in the `server_info` attribute
raise RuntimeError('Error when connecting to {}: {}'.format(e.server_info.hostname, e.error_message))
# Then run scan commands using server_info...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment