Skip to content

Commit

Permalink
[fix] #38 - exception handling in case of wrong ca_chain
Browse files Browse the repository at this point in the history
  • Loading branch information
grindsa committed Jul 2, 2020
1 parent 057ba57 commit 89e8638
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions examples/ca_handler/xca_ca_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,16 +184,18 @@ def _cert_insert(self, cert_dic):

def _cert_search(self, column, value):
""" load ca key from database """
self.logger.debug('CAhandler._cert_search()')
self.logger.debug('CAhandler._cert_search({0}:{1})'.format(column, value))

# query database for key
self._db_open()
pre_statement = '''SELECT * from items WHERE type == 3 and {0} LIKE ?'''.format(column)
self.cursor.execute(pre_statement, [value])

cert_result = {}
try:
item_result = dict_from_row(self.cursor.fetchone())
except BaseException:
self.logger.error('CAhandler._cert_search(): item search failed: {0}'.format(self.cursor.fetchone()))
item_result = {}

if item_result:
Expand All @@ -203,7 +205,7 @@ def _cert_search(self, column, value):
try:
cert_result = dict_from_row(self.cursor.fetchone())
except BaseException:
cert_result = {}
self.logger.error('CAhandler._cert_search(): cert search failed: item: {0}'.format(item_id))

self._db_close()
self.logger.debug('CAhandler._cert_search() ended')
Expand Down

0 comments on commit 89e8638

Please sign in to comment.