mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Handle base64-encoded certificates better, import missing function
This commit is contained in:
parent
29f243bf4e
commit
af20a1a2da
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user