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

Function DER_cert_to_PEM_cert

Lib/ssl.py:1483–1491  ·  view source on GitHub ↗

Takes a certificate in binary DER format and returns the PEM version of it as a string.

(der_cert_bytes)

Source from the content-addressed store, hash-verified

1481PEM_FOOTER = "-----END CERTIFICATE-----"
1482
1483def DER_cert_to_PEM_cert(der_cert_bytes):
1484 """Takes a certificate in binary DER format and returns the
1485 PEM version of it as a string."""
1486
1487 f = str(base64.standard_b64encode(der_cert_bytes), 'ASCII', 'strict')
1488 ss = [PEM_HEADER]
1489 ss += [f[i:i+64] for i in range(0, len(f), 64)]
1490 ss.append(PEM_FOOTER + '\n')
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

Callers 1

get_server_certificateFunction · 0.70

Calls 4

strFunction · 0.85
lenFunction · 0.85
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected