Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in reading pem file in processIncomingRequest #55

Open
xtanion opened this issue May 29, 2023 · 1 comment
Open

Error in reading pem file in processIncomingRequest #55

xtanion opened this issue May 29, 2023 · 1 comment

Comments

@xtanion
Copy link
Contributor

xtanion commented May 29, 2023

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
Copy link

!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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants