mirror of
https://github.com/micropython/micropython.git
synced 2026-01-07 04:30:24 +01:00
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:
committed by
Damien George
parent
ace9fb5405
commit
d5191edf7f
21
tests/net_hosted/ssl_getpeercert.py
Normal file
21
tests/net_hosted/ssl_getpeercert.py
Normal 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])
|
||||
1
tests/net_hosted/ssl_getpeercert.py.exp
Normal file
1
tests/net_hosted/ssl_getpeercert.py.exp
Normal file
@@ -0,0 +1 @@
|
||||
<class 'bytes'> True
|
||||
Reference in New Issue
Block a user