Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions make/DEBIAN/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
Package: Testrun
<<<<<<< revert
Version: 2.3.4-beta.2
=======
Version: 2.4.0-beta.1
>>>>>>> dev
Architecture: amd64
Maintainer: Google <ssm-orcas@google.com>
Homepage: https://github.com/google/testrun
Expand Down
37 changes: 15 additions & 22 deletions modules/test/tls/python/src/tls_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,27 +148,22 @@ def get_public_certificate(self,
cert_pem = ssl.DER_cert_to_PEM_cert(secure_sock.getpeercert(True))

except ConnectionRefusedError:
error_msg = f'Connection to {host}:{port} was refused.'
LOGGER.info(error_msg)
return None, error_msg
LOGGER.info(f'Connection to {host}:{port} was refused.')
return None
except socket.gaierror:
error_msg = f'Failed to resolve the hostname {host}.'
LOGGER.info(error_msg)
return None, error_msg
LOGGER.info(f'Failed to resolve the hostname {host}.')
return None
except ssl.SSLError as e:
error_msg = f'SSL error occurred: {e}'
LOGGER.info(error_msg)
return None, error_msg
LOGGER.info(f'SSL error occurred: {e}')
return None
except socket.timeout:
error_msg = 'Socket timeout error'
LOGGER.info(error_msg)
return None, error_msg
LOGGER.info('Socket timeout error')
return None
except OSError as e:
error_msg = e
LOGGER.info(error_msg)
return None, error_msg
LOGGER.error(e)
return None

return cert_pem, None
return cert_pem

def get_public_key(self, public_cert):
# Extract and return the public key from the certificate
Expand Down Expand Up @@ -341,7 +336,7 @@ def validate_trusted_ca_signature(self, host, port):
# within the valid CA root certs stored on the server
LOGGER.info(
'Checking for valid signature from authorized Certificate Authorities')
public_cert, _ = self.get_public_certificate(host=host,
public_cert = self.get_public_certificate(host=host,
port=port,
validate_cert=True,
tls_version='1.2')
Expand Down Expand Up @@ -510,7 +505,7 @@ def validate_tls_server(self,
tls_version: str,
port: int=443
) -> tuple[bool| None, list| str]:
cert_pem, error_reason = self.get_public_certificate(host=host,
cert_pem = self.get_public_certificate(host=host,
port=port,
validate_cert=False,
tls_version=tls_version)
Expand Down Expand Up @@ -545,10 +540,8 @@ def validate_tls_server(self,
LOGGER.info('Certificate validated: ' + str(cert_valid))
return cert_valid, details
else:
final_msg = error_reason \
or f'No TLS {tls_version} server functionality found'
LOGGER.info(final_msg)
return None, [final_msg]
LOGGER.info('Failed to resolve public certificate')
return None, ['Failed to resolve public certificate']

def write_cert_to_file(self, cert_name, cert):
try:
Expand Down
Loading