Skip to content

Error importing public certificate #29

Open
@JamesInform

Description

@JamesInform

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions