-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from JayH5/http-01-challenge
First (very incomplete) attempt at http-01 challenge type
- Loading branch information
Showing
4 changed files
with
106 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from ._http import HTTP01Responder | ||
from ._tls import TLSSNI01Responder | ||
|
||
__all__ = ['TLSSNI01Responder'] | ||
__all__ = ['HTTP01Responder', 'TLSSNI01Responder'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
""" | ||
``http-01`` challenge implementation. | ||
""" | ||
from twisted.web.resource import Resource | ||
from twisted.web.static import Data | ||
|
||
from zope.interface import implementer | ||
|
||
from txacme.interfaces import IResponder | ||
|
||
|
||
@implementer(IResponder) | ||
class HTTP01Responder(object): | ||
""" | ||
An ``http-01`` challenge responder for txsni. | ||
""" | ||
challenge_type = u'http-01' | ||
|
||
def __init__(self): | ||
self.resource = Resource() | ||
|
||
def start_responding(self, server_name, challenge, response): | ||
""" | ||
Add the child resource. | ||
""" | ||
self.resource.putChild( | ||
challenge.encode('token').encode('utf-8'), | ||
Data(response.key_authorization.encode('utf-8'), 'text/plain')) | ||
|
||
def stop_responding(self, server_name, challenge, response): | ||
""" | ||
Remove the child resource. | ||
""" | ||
encoded_token = challenge.encode('token').encode('utf-8') | ||
if self.resource.getStaticEntity(encoded_token) is not None: | ||
self.resource.delEntity(encoded_token) | ||
|
||
|
||
__all__ = ['HTTP01Responder'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
``txacme.challenges.HTTP01Responder``, an http-01 challenge responder that can be embedded into an existing twisted.web application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters