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 importing public certificate #29

Open
JamesInform opened this issue Jan 20, 2021 · 0 comments
Open

Error importing public certificate #29

JamesInform opened this issue Jan 20, 2021 · 0 comments

Comments

@JamesInform
Copy link

Hi!

Importing a valid public key ".cer" file, I run into a server 500 error your django pyas2 (v1.2.0)

I switched to debug and found that you do a plain item.decode("utf8").

In utils.py function "extract_certificate_info" you do this e.g. in line 248
cert_info["subject"] = [ tuple(item.decode("utf8") for item in sets) for sets in certificate.get_subject().get_components() ]

If there is a non valid utf8 token in the subject, the function crashes.

The easy fix is to instruct the decode function to escape all non utf8 characters with a simple and convenient parameter in Python 3+:

item.decode("utf8","backslashreplace")

Maybe this can be used for all relevant utf8 decodings

Cheers James

chadgates added a commit to chadgates/pyas2-lib that referenced this issue Jan 5, 2022
chadgates added a commit to chadgates/pyas2-lib that referenced this issue Jan 6, 2022
chadgates added a commit to chadgates/pyas2-lib that referenced this issue Jan 6, 2022
chadgates added a commit to chadgates/pyas2-lib that referenced this issue Jan 10, 2022
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

1 participant