summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2014-09-18 11:42:14 +0200
committerMartin Kosek <mkosek@redhat.com>2014-09-30 10:01:38 +0200
commitb764e9d3e6fcd380c9420c2d442293fdd12ec5dc (patch)
tree9b8f8b78d259c01e93c1e2b6b3ab2af68f826b80
parent86c534df7de353662078feb9128e8125d89474f1 (diff)
downloadfreeipa-b764e9d3e6fcd380c9420c2d442293fdd12ec5dc.tar.gz
freeipa-b764e9d3e6fcd380c9420c2d442293fdd12ec5dc.tar.xz
freeipa-b764e9d3e6fcd380c9420c2d442293fdd12ec5dc.zip
Add NSSDatabase.has_nickname for checking nickname presence in a NSS DB
https://fedorahosted.org/freeipa/ticket/4416 Reviewed-By: Rob Crittenden <rcritten@redhat.com>
-rw-r--r--ipapython/certdb.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/ipapython/certdb.py b/ipapython/certdb.py
index e190a7093..792cd7529 100644
--- a/ipapython/certdb.py
+++ b/ipapython/certdb.py
@@ -406,6 +406,15 @@ class NSSDatabase(object):
raise RuntimeError("Failed to get %s" % nickname)
return cert
+ def has_nickname(self, nickname):
+ try:
+ self.get_cert(nickname)
+ except RuntimeError:
+ # This might be error other than "nickname not found". Beware.
+ return False
+ else:
+ return True
+
def export_pem_cert(self, nickname, location):
"""Export the given cert to PEM file in the given location"""
cert = self.get_cert(nickname)