diff options
author | Ruben Pollan <meskio@sindominio.net> | 2015-11-18 00:27:56 +0100 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2015-12-09 19:21:58 +0100 |
commit | 8fc1258ace65be2bb828bf302fc0661cdd128bd7 (patch) | |
tree | 705ff34d8d077eb5a3d752468161fe345082211d /src/leap/mx/couchdbhelper.py | |
parent | 3360cc70b7752f6ebedb56cb8ffc01b81cd640d6 (diff) |
[feat] postfix lookup against couchdb for client smtp fingerprint
- Resolves: #4285
Diffstat (limited to 'src/leap/mx/couchdbhelper.py')
-rw-r--r-- | src/leap/mx/couchdbhelper.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/leap/mx/couchdbhelper.py b/src/leap/mx/couchdbhelper.py index 115ecbe..de133d5 100644 --- a/src/leap/mx/couchdbhelper.py +++ b/src/leap/mx/couchdbhelper.py @@ -138,6 +138,34 @@ class ConnectedCouchDB(client.CouchDB): d.addCallbacks(_get_pubkey_cbk, log.err) return d + def getCertExpiry(self, fingerprint): + """ + Query couch and return a deferred that will fire with the expiration + date for the cert with the given fingerprint. + + :param fingerprint: The cert fingerprint + :type fingerprint: str + + :return: A deferred that will fire with the cert expiration date as a + str. + :rtype: Deferred + """ + d = self.openView(docId="Identity", + viewId="cert_expiry_by_fingerprint/", + key=fingerprint, + reduce=False, + include_docs=True) + + def _get_cert_expiry_cbk(result): + try: + expiry = result["rows"][0]["value"] + except (KeyError, IndexError): + expiry = None + return expiry + + d.addCallback(_get_cert_expiry_cbk) + return d + def put_doc(self, uuid, doc): """ Update a document. |