summaryrefslogtreecommitdiff
path: root/tests/net_hosted/ssl_getpeercert.py
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2023-12-12 17:15:24 +1100
committerDamien George <damien@micropython.org>2023-12-12 21:21:54 +1100
commitef996d15b9cbadee591a185f27fb16e90a5d4f5d (patch)
tree595af344ea1e59e1c0813897df3152680acc662b /tests/net_hosted/ssl_getpeercert.py
parentc9eb6bc6016a7f13cc624b6a4160599ab6b166ff (diff)
extmod/modssl_mbedtls: Make SSLSocket.getpeercert() optional.
And only enable this method when the relevant feature is available in mbedtls. Otherwise, if mbedtls doesn't support getting the peer certificate, this method always returns None and it's confusing why it does that. It's better to remove the method altogether, so the error trying to use it is more obvious. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'tests/net_hosted/ssl_getpeercert.py')
-rw-r--r--tests/net_hosted/ssl_getpeercert.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/tests/net_hosted/ssl_getpeercert.py b/tests/net_hosted/ssl_getpeercert.py
index 0df895a65..e0a1350fa 100644
--- a/tests/net_hosted/ssl_getpeercert.py
+++ b/tests/net_hosted/ssl_getpeercert.py
@@ -1,8 +1,15 @@
# test ssl.getpeercert() method
+import io
import socket
import ssl
+s_test = ssl.wrap_socket(io.BytesIO(), server_side=True, do_handshake=False)
+s_test.close()
+if not hasattr(s_test, "getpeercert"):
+ print("SKIP")
+ raise SystemExit
+
def test(peer_addr):
s = socket.socket()