Takes a certificate in ASCII PEM format and returns the DER-encoded version of it as a byte sequence
(pem_cert_string)
| 1491 | return '\n'.join(ss) |
| 1492 | |
| 1493 | def 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 | |
| 1506 | def get_server_certificate(addr, ssl_version=PROTOCOL_TLS_CLIENT, |
| 1507 | ca_certs=None, timeout=_GLOBAL_DEFAULT_TIMEOUT): |
nothing calls this directly
no test coverage detected