Last active
March 4, 2018 18:58
-
-
Save nabla-c0d3/91d6544018e75efe4385b2f4409854ab to your computer and use it in GitHub Desktop.
Migrating to SSLyze 1.4.0
This file contains 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
# 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