-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathacmechallenge.py
36 lines (28 loc) · 1.21 KB
/
acmechallenge.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
""" acmechallenge class """
from __future__ import print_function
from acme_srv.db_handler import DBstore
class Acmechallenge(object):
""" Acmechallenge handler """
def __init__(self, debug=None, srv_name=None, logger=None):
self.server_name = srv_name
self.debug = debug
self.logger = logger
self.dbstore = DBstore(self.debug, self.logger)
def __enter__(self):
""" Makes ACMEHandler a Context Manager """
return self
def __exit__(self, *args):
""" cose the connection at the end of the context """
def lookup(self, path_info: str) -> str:
""" check nonce """
self.logger.debug('Acmechallenge.lookup()')
key_authorization = None
if path_info:
token = path_info.replace('/.well-known/acme-challenge/', '')
self.logger.info('Acmechallenge.lookup() token: %s', token)
challenge_dic = self.dbstore.cahandler_lookup('name', token)
if challenge_dic and 'value1' in challenge_dic:
key_authorization = challenge_dic['value1']
self.logger.debug('Acmechallenge.lookup() ended with: %s', key_authorization)
return key_authorization