Parse the provided base64 encoded string or DER encoded bytes. For PEM files, the parser assumes that the header and footer exists. If you have the PEM base64 without headers, addHeaders will add them for you. Returns None if there is an error.
(self, cert_data, certSource, addHeaders=False)
| 973 | return cert_object |
| 974 | |
| 975 | def parse_data(self, cert_data, certSource, addHeaders=False): |
| 976 | """ |
| 977 | Parse the provided base64 encoded string or DER encoded bytes. |
| 978 | For PEM files, the parser assumes that the header and footer exists. |
| 979 | If you have the PEM base64 without headers, addHeaders will add them for you. |
| 980 | Returns None if there is an error. |
| 981 | """ |
| 982 | if addHeaders: |
| 983 | data = bytes( |
| 984 | "-----BEGIN CERTIFICATE-----\n" |
| 985 | + cert_data |
| 986 | + "\n-----END CERTIFICATE-----", |
| 987 | "UTF-8", |
| 988 | ) |
| 989 | else: |
| 990 | if type(cert_data) is str: |
| 991 | data = bytes(cert_data, "utf-8") |
| 992 | else: |
| 993 | data = bytes(cert_data) |
| 994 | |
| 995 | cert_object = self.__parse(data, certSource) |
| 996 | return cert_object |
no test coverage detected