mirror of
https://github.com/moepman/acertmgr.git
synced 2025-01-01 04:21:51 +01:00
standalone: Fix server start+stop with multiple handlers
This commit is contained in:
parent
48a55c0dc4
commit
3570baacda
@ -131,6 +131,8 @@ class ACMEAuthority(AbstractACMEAuthority):
|
||||
time.sleep(1)
|
||||
|
||||
for domain in domains:
|
||||
challenge_handlers[domain].start_challenge()
|
||||
try:
|
||||
print("Starting key authorization")
|
||||
# notify challenge are met
|
||||
keyauthorization = "{0}.{1}".format(tokens[domain], account_thumbprint)
|
||||
@ -158,7 +160,11 @@ class ACMEAuthority(AbstractACMEAuthority):
|
||||
raise ValueError("{0} challenge did not pass: {1}".format(
|
||||
domain, challenge_status))
|
||||
finally:
|
||||
for domain in domains:
|
||||
challenge_handlers[domain].stop_challenge()
|
||||
finally:
|
||||
# Destroy challenge handlers in reverse order to replay
|
||||
# any saved state information in the handlers correctly
|
||||
for domain in reversed(domains):
|
||||
try:
|
||||
challenge_handlers[domain].destroy_challenge(domain, account_thumbprint, tokens[domain])
|
||||
except:
|
||||
|
@ -20,3 +20,11 @@ class AbstractChallengeHandler:
|
||||
|
||||
def destroy_challenge(self, domain, thumbprint, token):
|
||||
raise NotImplemented
|
||||
|
||||
# Optional: Indicate when a challenge request is imminent
|
||||
def start_challenge(self):
|
||||
pass
|
||||
|
||||
# Optional: Indicate when a challenge response has been received
|
||||
def stop_challenge(self):
|
||||
pass
|
||||
|
@ -70,15 +70,12 @@ class ChallengeHandler(WebChallengeHandler):
|
||||
self.server_thread = None
|
||||
self.server = HTTPServer(("", port), ACMERequestHandler)
|
||||
|
||||
def create_challenge(self, domain, thumbprint, token):
|
||||
WebChallengeHandler.create_challenge(self, domain, thumbprint, token)
|
||||
def start_challenge(self):
|
||||
self.server_thread = threading.Thread(target=start_standalone, args=(self.server,))
|
||||
os.chdir(self.challenge_directory)
|
||||
self.server_thread.start()
|
||||
return datetime.datetime.now()
|
||||
|
||||
def destroy_challenge(self, domain, thumbprint, token):
|
||||
def stop_challenge(self):
|
||||
self.server.shutdown()
|
||||
self.server_thread.join()
|
||||
os.chdir(self.current_directory)
|
||||
WebChallengeHandler.destroy_challenge(self, domain, thumbprint, token)
|
||||
|
Loading…
Reference in New Issue
Block a user