summaryrefslogtreecommitdiffstats
path: root/ipalib/x509.py
diff options
context:
space:
mode:
authorTomas Babej <tbabej@redhat.com>2014-11-20 18:37:57 +0100
committerPetr Viktorin <pviktori@dhcp-31-13.brq.redhat.com>2014-11-26 13:06:35 +0100
commit792ff0c0c40ddd1583c6789c8f34382c050d3e92 (patch)
treee00b8e239dbce632ce8f027f99063cd588f13fda /ipalib/x509.py
parentb3a6701e73f6ccd4dff1dab47554381f42d40bb4 (diff)
downloadfreeipa-792ff0c0c40ddd1583c6789c8f34382c050d3e92.tar.gz
freeipa-792ff0c0c40ddd1583c6789c8f34382c050d3e92.tar.xz
freeipa-792ff0c0c40ddd1583c6789c8f34382c050d3e92.zip
Re-initialize NSS database after otptoken plugin tests
OTP token tests do not properly reinitialize the NSS db, thus making subsequent xmlrpc tests fail on SSL cert validation. Make sure NSS db is re-initalized in the teardown method. https://fedorahosted.org/freeipa/ticket/4748 Reviewed-By: Petr Viktorin <pviktori@redhat.com>
Diffstat (limited to 'ipalib/x509.py')
-rw-r--r--ipalib/x509.py31
1 files changed, 20 insertions, 11 deletions
diff --git a/ipalib/x509.py b/ipalib/x509.py
index 88ea415bf..a87dbf413 100644
--- a/ipalib/x509.py
+++ b/ipalib/x509.py
@@ -89,19 +89,12 @@ def strip_header(pem):
return pem
-def load_certificate(data, datatype=PEM, dbdir=None):
+def initialize_nss_database(dbdir=None):
"""
- Given a base64-encoded certificate, with or without the
- header/footer, return a request object.
-
- Returns a nss.Certificate type
+ Initializes NSS database, if not initialized yet. Uses a proper database
+ directory (.ipa/alias or HTTPD_ALIAS_DIR), depending on the value of
+ api.env.in_tree.
"""
- if type(data) in (tuple, list):
- data = data[0]
-
- if (datatype == PEM):
- data = strip_header(data)
- data = base64.b64decode(data)
if not nss.nss_is_initialized():
if dbdir is None:
@@ -116,6 +109,22 @@ def load_certificate(data, datatype=PEM, dbdir=None):
else:
nss.nss_init(dbdir)
+def load_certificate(data, datatype=PEM, dbdir=None):
+ """
+ Given a base64-encoded certificate, with or without the
+ header/footer, return a request object.
+
+ Returns a nss.Certificate type
+ """
+ if type(data) in (tuple, list):
+ data = data[0]
+
+ if (datatype == PEM):
+ data = strip_header(data)
+ data = base64.b64decode(data)
+
+ initialize_nss_database(dbdir=dbdir)
+
return nss.Certificate(buffer(data))
def load_certificate_from_file(filename, dbdir=None):