Once the data is in a bytes format, transform it using cryptography and pyOpenSSL Then, create a cert_object to return to the original caller.
(self, data, certSource)
| 926 | return bytes |
| 927 | |
| 928 | def __parse(self, data, certSource): |
| 929 | """ |
| 930 | Once the data is in a bytes format, transform it using cryptography and pyOpenSSL |
| 931 | Then, create a cert_object to return to the original caller. |
| 932 | """ |
| 933 | cert = None |
| 934 | try: |
| 935 | cert = x509.load_pem_x509_certificate(data, default_backend()) |
| 936 | openssl_cert = crypto.load_certificate(crypto.FILETYPE_PEM, data) |
| 937 | except: |
| 938 | self._logger.debug("WARNING: Could not parse certificate as a PEM file") |
| 939 | |
| 940 | try: |
| 941 | cert = x509.load_der_x509_certificate(data, default_backend()) |
| 942 | openssl_cert = crypto.load_certificate(crypto.FILETYPE_ASN1, data) |
| 943 | except Exception as e: |
| 944 | self._logger.debug( |
| 945 | "WARNING: Could not parse certificate as a PEM or DER file - " |
| 946 | + str(e) |
| 947 | ) |
| 948 | return None |
| 949 | |
| 950 | cert_object = self.__create_mongodb_structure(cert, openssl_cert) |
| 951 | if cert_object is None: |
| 952 | return None |
| 953 | |
| 954 | cert_object["sources"] = [] |
| 955 | cert_object["sources"].append(certSource) |
| 956 | |
| 957 | cert_object["marinus_createdate"] = datetime.now() |
| 958 | cert_object["marinus_updated"] = datetime.now() |
| 959 | |
| 960 | return cert_object |
| 961 | |
| 962 | def parse_file(self, file_name, certSource): |
| 963 | """ |
no test coverage detected