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>
This commit is contained in:
Damien George
2023-12-12 17:15:24 +11:00
parent c9eb6bc601
commit ef996d15b9
4 changed files with 20 additions and 2 deletions

View File

@@ -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()