Skip to content

Commit 1fc7233

Browse files
committed
handle client certs
1 parent 9b5bcdd commit 1fc7233

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

showcert/__about__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = '0.4.5'
1+
__version__ = '0.4.6'

showcert/getremote.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,21 +119,16 @@ def get_certificate_chain(host, name=None, port=443, insecure=False, starttls='a
119119

120120
conn.set_connect_state()
121121

122-
if insecure:
123-
try:
124-
conn.do_handshake()
125-
except SSL.Error as e:
126-
# rare case, e.g. RabbitMQ on 5671 which reset connection if client certificate is not sent
127-
# never happens on webservers
128-
errors = e.args[0]
129-
for lib, func, reason in errors:
130-
# print(f"{lib=} {func=} {reason=}")
131-
if "handshake failure" in reason.lower():
132-
print("# Server likely requires a client certificate (handshake failure)")
133-
134-
else:
122+
try:
135123
conn.do_handshake()
136-
124+
except SSL.Error as e:
125+
# rare case, e.g. RabbitMQ on 5671 which reset connection if client certificate is not sent
126+
# never happens on webservers
127+
if insecure and 'ssl/tls alert handshake failure' in str(e):
128+
print("# Server likely requires a client certificate (handshake failure)")
129+
else:
130+
raise
131+
137132
if conn.get_client_ca_list():
138133
print("# Remote asks for a client certificate")
139134

0 commit comments

Comments
 (0)