Handle base64-encoded certificates better, import missing function
This commit is contained in:
1 parent
29f243bf4e
commit
af20a1a2da
3 files changed
+11
No files matched your search
@@ -53,6 +53,11 @@ def get_serial(certificate):
|
||||
if type(certificate) in (list, tuple):
|
||||
certificate = certificate[0]
|
||||
try:
|
||||
certificate = base64.b64decode(certificate)
|
||||
except Exception, e:
|
||||
pass
|
||||
try:
|
||||
|
||||
serial = x509.get_serial_number(certificate)
|
||||
except PyAsn1Error:
|
||||
raise errors.CertificateOperationError(error=_('Unable to decode certificate in entry'))
|
||||
|
||||
@@ -30,6 +30,7 @@ from ipalib import Str, Flag, Bytes
|
||||
from ipalib.plugins.baseldap import *
|
||||
from ipalib.plugins.service import split_principal
|
||||
from ipalib.plugins.service import validate_certificate
|
||||
from ipalib.plugins.service import get_serial
|
||||
from ipalib import _, ngettext
|
||||
import base64
|
||||
|
||||
|
||||
@@ -37,6 +37,11 @@ def get_serial(certificate):
|
||||
"""
|
||||
if type(certificate) in (list, tuple):
|
||||
certificate = certificate[0]
|
||||
try:
|
||||
certificate = base64.b64decode(certificate)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
try:
|
||||
serial = x509.get_serial_number(certificate, type=x509.DER)
|
||||
except PyAsn1Error:
|
||||
|
||||
Reference in new issue
Block a user