extmod/modussl_mbedtls.c: Add ussl.getpeercert() method.

Behaviour is as per CPython but only the binary form is implemented here.
A test is included.
This commit is contained in:
Eric Poulsen
2017-08-15 07:49:11 -07:00
committed by Damien George
parent ace9fb5405
commit d5191edf7f
3 changed files with 34 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
# test ssl.getpeercert() method
try:
import usocket as socket
import ussl as ssl
except:
import socket
import ssl
def test(peer_addr):
s = socket.socket()
s.connect(peer_addr)
s = ssl.wrap_socket(s)
cert = s.getpeercert(True)
print(type(cert), len(cert) > 100)
s.close()
if __name__ == "__main__":
test(socket.getaddrinfo('micropython.org', 443)[0][-1])

View File

@@ -0,0 +1 @@
<class 'bytes'> True