[attributs.certificat] Belle erreur sur les certificats mal formaté
This commit is contained in:
parent
99d864b81c
commit
79149ebb4f
1 changed files with 8 additions and 5 deletions
|
@ -1517,13 +1517,16 @@ class certificat(Attr):
|
|||
|
||||
def _format_cert(self, certificat):
|
||||
import OpenSSL
|
||||
try:
|
||||
if certificat.startswith('-----BEGIN CERTIFICATE-----'):
|
||||
certificat = ssl.PEM_cert_to_DER_cert(certificat)
|
||||
try:
|
||||
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, certificat)
|
||||
except:
|
||||
except Exception:
|
||||
try:
|
||||
certificat = base64.b64decode(certificat)
|
||||
x509 = OpenSSL.crypto.load_certificate(OpenSSL.crypto.FILETYPE_ASN1, certificat)
|
||||
except Exception:
|
||||
raise ValueError("Format du certificat invalide, est-il bien au format DER ou PEM ?")
|
||||
data = {}
|
||||
data['subject'] = dict(x509.get_subject().get_components())
|
||||
data['issuer'] = dict(x509.get_issuer().get_components())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue