MCPcopy Index your code
hub / github.com/RustPython/RustPython / PEM_cert_to_DER_cert

Function PEM_cert_to_DER_cert

Lib/ssl.py:1493–1504  ·  view source on GitHub ↗

Takes a certificate in ASCII PEM format and returns the DER-encoded version of it as a byte sequence

(pem_cert_string)

Source from the content-addressed store, hash-verified

1491 return '\n'.join(ss)
1492
1493def PEM_cert_to_DER_cert(pem_cert_string):
1494 """Takes a certificate in ASCII PEM format and returns the
1495 DER-encoded version of it as a byte sequence"""
1496
1497 if not pem_cert_string.startswith(PEM_HEADER):
1498 raise ValueError("Invalid PEM encoding; must start with %s"
1499 % PEM_HEADER)
1500 if not pem_cert_string.strip().endswith(PEM_FOOTER):
1501 raise ValueError("Invalid PEM encoding; must end with %s"
1502 % PEM_FOOTER)
1503 d = pem_cert_string.strip()[len(PEM_HEADER):-len(PEM_FOOTER)]
1504 return base64.decodebytes(d.encode('ASCII', 'strict'))
1505
1506def get_server_certificate(addr, ssl_version=PROTOCOL_TLS_CLIENT,
1507 ca_certs=None, timeout=_GLOBAL_DEFAULT_TIMEOUT):

Callers

nothing calls this directly

Calls 5

lenFunction · 0.85
startswithMethod · 0.45
endswithMethod · 0.45
stripMethod · 0.45
encodeMethod · 0.45

Tested by

no test coverage detected