Check if present - Organization, State, Country
This commit is contained in:
parent
2ccb7034b5
commit
43483cb1c7
|
@ -95,9 +95,11 @@ def organization(cert):
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return cert.subject.get_attributes_for_oid(x509.OID_ORGANIZATION_NAME)[
|
o = cert.subject.get_attributes_for_oid(x509.OID_ORGANIZATION_NAME)
|
||||||
0
|
if not o:
|
||||||
].value.strip()
|
return None
|
||||||
|
|
||||||
|
return o[0].value.strip()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sentry.captureException()
|
sentry.captureException()
|
||||||
current_app.logger.error("Unable to get organization! {0}".format(e))
|
current_app.logger.error("Unable to get organization! {0}".format(e))
|
||||||
|
@ -127,9 +129,11 @@ def country(cert):
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return cert.subject.get_attributes_for_oid(x509.OID_COUNTRY_NAME)[
|
c = cert.subject.get_attributes_for_oid(x509.OID_COUNTRY_NAME)
|
||||||
0
|
if not c:
|
||||||
].value.strip()
|
return None
|
||||||
|
|
||||||
|
return c[0].value.strip()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sentry.captureException()
|
sentry.captureException()
|
||||||
current_app.logger.error("Unable to get country! {0}".format(e))
|
current_app.logger.error("Unable to get country! {0}".format(e))
|
||||||
|
@ -142,9 +146,11 @@ def state(cert):
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
return cert.subject.get_attributes_for_oid(x509.OID_STATE_OR_PROVINCE_NAME)[
|
s = cert.subject.get_attributes_for_oid(x509.OID_STATE_OR_PROVINCE_NAME)
|
||||||
0
|
if not s:
|
||||||
].value.strip()
|
return None
|
||||||
|
|
||||||
|
return s[0].value.strip()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sentry.captureException()
|
sentry.captureException()
|
||||||
current_app.logger.error("Unable to get state! {0}".format(e))
|
current_app.logger.error("Unable to get state! {0}".format(e))
|
||||||
|
|
Loading…
Reference in New Issue