Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash: Legacy sslclient can not build verified chain #386

Merged
merged 2 commits into from Sep 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions sslyze/plugins/http_headers_plugin.py
Expand Up @@ -57,6 +57,10 @@ def process_task(
verified_chain_as_pem = ssl_connection.ssl_client.get_verified_chain()
except CouldNotBuildVerifiedChain:
verified_chain_as_pem = None
except AttributeError:
# Only the modern SSL Client can build the verified chain; hence we get here if the server only supports
# an older version of TLS (pre 1.2)
verified_chain_as_pem = None

# Send an HTTP GET request to the server
ssl_connection.ssl_client.write(HttpRequestGenerator.get_request(host=server_info.hostname))
Expand Down
12 changes: 12 additions & 0 deletions tests/plugin_tests/test_http_headers_plugin.py
Expand Up @@ -141,3 +141,15 @@ def test_works_when_client_auth_succeeded(self):
assert plugin_result.expect_ct_header is None
assert plugin_result.as_text()
assert plugin_result.as_xml()

def test_legacy_ssl_client_missing_verified_chain(self):
# Given a tls1.0 server
server_test = ServerConnectivityTester(hostname='tls-v1-0.badssl.com', port=1010)
server_info = server_test.perform()

# The plugin does not throw an exception trying to access LegacySslClient.get_verified_chain()
plugin = HttpHeadersPlugin()
plugin_result = plugin.process_task(server_info, HttpHeadersScanCommand())

assert plugin_result.as_text()
assert plugin_result.as_xml()