Skip to content
This repository has been archived by the owner on Dec 6, 2023. It is now read-only.

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
yzninja committed Sep 15, 2015
1 parent 2f35f62 commit cfdfa0a
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 deletions nogotofail/mitm/connection/handlers/data/ssl.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,6 @@ def on_response(self, response):
if (isinstance(message, tls.types.HandshakeMessage) and
message.type == HandshakeMessage.TYPE.CERTIFICATE):
certificate = message.obj

if certificate.certificates:
# Check leaf certificate in chain for SHA-1 sunset issue
crt_byte_string = certificate.certificates[0]
Expand All @@ -135,24 +134,19 @@ def on_response(self, response):
crt_signature_algorithm = \
a_certificate.get_signature_algorithm()
if ("sha1" in crt_signature_algorithm):
crt_CN = \
str(a_certificate.get_subject().CN or "")
crt_not_before = \
str(a_certificate.get_notBefore() or "")
crt_not_after = \
str(a_certificate.get_notAfter() or "")
crt_CN = str(a_certificate.get_subject().CN or "")
crt_not_before = str(a_certificate.get_notBefore() or "")
crt_not_after = str(a_certificate.get_notAfter() or "")
debug_message = \
["Certicate using SHA-1 with attributes - CN \"",
self._str_trans(crt_CN),
"\", notBefore \"", crt_not_before,
crt_CN, "\", notBefore \"", crt_not_before,
"\", notAfter \"", crt_not_after,
"\", signature_algorithm \"",
crt_signature_algorithm, "\""]
self.log(logging.DEBUG, "".join(debug_message))
crt_not_after = datetime.strptime(crt_not_after,
CRT_DATE_FORMAT)
self._alert_on_sunset_sha1(crt_not_after, crt_CN)
count += 1
index += size
except ValueError:
# Failed to parse TLS, this is probably due to a short read of a TLS
Expand Down Expand Up @@ -200,8 +194,3 @@ def _alert_on_sunset_sha1(self, crt_not_after, crt_CN):
self.log_event(logging.WARNING, connection.AttackEvent(
self.connection, self.name, True, ""))
self.connection.vuln_notify(util.vuln.VULN_SUNSET_SHA1)

def _str_trans(self, s):
""" Converts objects to strings, and "None" objects to empty strings.
"""
return '' if s is None else str(s)

0 comments on commit cfdfa0a

Please sign in to comment.