Swasth-Digital-Health-Foundation / integration-sdks

MIT License
5 stars 19 forks source link

Error in reading pem file in `processIncomingRequest` #55

Open xtanion opened 1 year ago

xtanion commented 1 year ago

While running testHcxUtils.py I'm getting the following error:

    return rust_x509.load_pem_x509_certificate(data)
ValueError: Unable to load PEM file. See https://cryptography.io/en/latest/faq/#why-can-t-i-import-my-pem-file for more details. MalformedFraming
AdityaSen-1606 commented 1 year ago

!pip install cryptography from cryptography.hazmat.backends import default_backend from cryptography.hazmat.primitives import serialization

def load_pem_file(file_path): with open(file_path, 'rb') as pem_file: pem_data = pem_file.read()

Load PEM data into an X509 certificate object

    certificate = serialization.load_pem_certificate(pem_data, default_backend())
    return certificate

Usage example

pem_file_path = r'D:\Python SDK\integration-sdks\python\rsa_public.pem' certificate = load_pem_file(pem_file_path)

try this code