fix starting Gajim when pyasn1 is not installed. see #7066
This commit is contained in:
parent
aa94671708
commit
9804572772
|
@ -1,3 +1,9 @@
|
||||||
|
import logging
|
||||||
|
log = logging.getLogger('gajim.c.check_X509')
|
||||||
|
|
||||||
|
try:
|
||||||
|
import OpenSSL.SSL
|
||||||
|
import OpenSSL.crypto
|
||||||
from pyasn1.type import univ, constraint, char, namedtype, tag
|
from pyasn1.type import univ, constraint, char, namedtype, tag
|
||||||
from pyasn1.codec.der.decoder import decode
|
from pyasn1.codec.der.decoder import decode
|
||||||
from common.helpers import prep, InvalidFormat
|
from common.helpers import prep, InvalidFormat
|
||||||
|
@ -92,10 +98,6 @@ class GeneralNames(univ.SequenceOf):
|
||||||
componentType = GeneralName()
|
componentType = GeneralName()
|
||||||
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
|
sizeSpec = univ.SequenceOf.sizeSpec + constraint.ValueSizeConstraint(1, MAX)
|
||||||
|
|
||||||
|
|
||||||
#s = '0\x1a\x82\rwww.gajim.org\x82\tgajim.org'
|
|
||||||
s = '0\x81\x86\x82\x0c*.jabber.org\x82\njabber.org\xa0\x1a\x06\x08+\x06\x01\x05\x05\x07\x08\x05\xa0\x0e\x0c\x0c*.jabber.org\xa0\x1a\x06\x08+\x06\x01\x05\x05\x07\x08\x07\xa0\x0e\x16\x0c*.jabber.org\xa0\x18\x06\x08+\x06\x01\x05\x05\x07\x08\x05\xa0\x0c\x0c\njabber.org\xa0\x18\x06\x08+\x06\x01\x05\x05\x07\x08\x07\xa0\x0c\x16\njabber.org'
|
|
||||||
|
|
||||||
def _parse_asn1(asn1):
|
def _parse_asn1(asn1):
|
||||||
obj = decode(asn1, asn1Spec=GeneralNames())[0]
|
obj = decode(asn1, asn1Spec=GeneralNames())[0]
|
||||||
r = {}
|
r = {}
|
||||||
|
@ -162,3 +164,12 @@ def check_certificate(cert, domain):
|
||||||
if subject.commonName == domain:
|
if subject.commonName == domain:
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
except ImportError:
|
||||||
|
log.warn('Import of PyOpenSSL or pyasn1 failed. Cannot correctly check '
|
||||||
|
'SSL certificate')
|
||||||
|
|
||||||
|
def check_certificate(cert, domain):
|
||||||
|
subject = cert.get_subject()
|
||||||
|
if subject.commonName == domain:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
Loading…
Reference in New Issue