Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Maunium
synapse
Commits
db5970ac
Unverified
Commit
db5970ac
authored
4 years ago
by
Patrick Cloke
Committed by
GitHub
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Convert ACME code to async/await. (#7989)
parent
d1008fe9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
changelog.d/7989.misc
+1
-0
1 addition, 0 deletions
changelog.d/7989.misc
synapse/app/homeserver.py
+6
-7
6 additions, 7 deletions
synapse/app/homeserver.py
synapse/handlers/acme.py
+4
-7
4 additions, 7 deletions
synapse/handlers/acme.py
with
11 additions
and
14 deletions
changelog.d/7989.misc
0 → 100644
+
1
−
0
View file @
db5970ac
Convert various parts of the codebase to async/await.
This diff is collapsed.
Click to expand it.
synapse/app/homeserver.py
+
6
−
7
View file @
db5970ac
...
@@ -380,13 +380,12 @@ def setup(config_options):
...
@@ -380,13 +380,12 @@ def setup(config_options):
hs
.
setup_master
()
hs
.
setup_master
()
@defer.inlineCallbacks
async
def
do_acme
()
->
bool
:
def
do_acme
():
"""
"""
Reprovision an ACME certificate, if it
'
s required.
Reprovision an ACME certificate, if it
'
s required.
Returns:
Returns:
Deferred[bool]:
Whether the cert has been updated.
Whether the cert has been updated.
"""
"""
acme
=
hs
.
get_acme_handler
()
acme
=
hs
.
get_acme_handler
()
...
@@ -405,7 +404,7 @@ def setup(config_options):
...
@@ -405,7 +404,7 @@ def setup(config_options):
provision
=
True
provision
=
True
if
provision
:
if
provision
:
yield
acme
.
provision_certificate
()
await
acme
.
provision_certificate
()
return
provision
return
provision
...
@@ -415,7 +414,7 @@ def setup(config_options):
...
@@ -415,7 +414,7 @@ def setup(config_options):
Provision a certificate from ACME, if required, and reload the TLS
Provision a certificate from ACME, if required, and reload the TLS
certificate if it
'
s renewed.
certificate if it
'
s renewed.
"""
"""
reprovisioned
=
yield
do_acme
()
reprovisioned
=
yield
defer
.
ensureDeferred
(
do_acme
()
)
if
reprovisioned
:
if
reprovisioned
:
_base
.
refresh_certificate
(
hs
)
_base
.
refresh_certificate
(
hs
)
...
@@ -427,8 +426,8 @@ def setup(config_options):
...
@@ -427,8 +426,8 @@ def setup(config_options):
acme
=
hs
.
get_acme_handler
()
acme
=
hs
.
get_acme_handler
()
# Start up the webservices which we will respond to ACME
# Start up the webservices which we will respond to ACME
# challenges with, and then provision.
# challenges with, and then provision.
yield
acme
.
start_listening
()
yield
defer
.
ensureDeferred
(
acme
.
start_listening
()
)
yield
do_acme
()
yield
defer
.
ensureDeferred
(
do_acme
()
)
# Check if it needs to be reprovisioned every day.
# Check if it needs to be reprovisioned every day.
hs
.
get_clock
().
looping_call
(
reprovision_acme
,
24
*
60
*
60
*
1000
)
hs
.
get_clock
().
looping_call
(
reprovision_acme
,
24
*
60
*
60
*
1000
)
...
...
This diff is collapsed.
Click to expand it.
synapse/handlers/acme.py
+
4
−
7
View file @
db5970ac
...
@@ -17,7 +17,6 @@ import logging
...
@@ -17,7 +17,6 @@ import logging
import
twisted
import
twisted
import
twisted.internet.error
import
twisted.internet.error
from
twisted.internet
import
defer
from
twisted.web
import
server
,
static
from
twisted.web
import
server
,
static
from
twisted.web.resource
import
Resource
from
twisted.web.resource
import
Resource
...
@@ -41,8 +40,7 @@ class AcmeHandler(object):
...
@@ -41,8 +40,7 @@ class AcmeHandler(object):
self
.
reactor
=
hs
.
get_reactor
()
self
.
reactor
=
hs
.
get_reactor
()
self
.
_acme_domain
=
hs
.
config
.
acme_domain
self
.
_acme_domain
=
hs
.
config
.
acme_domain
@defer.inlineCallbacks
async
def
start_listening
(
self
):
def
start_listening
(
self
):
from
synapse.handlers
import
acme_issuing_service
from
synapse.handlers
import
acme_issuing_service
# Configure logging for txacme, if you need to debug
# Configure logging for txacme, if you need to debug
...
@@ -82,18 +80,17 @@ class AcmeHandler(object):
...
@@ -82,18 +80,17 @@ class AcmeHandler(object):
self
.
_issuer
.
_registered
=
False
self
.
_issuer
.
_registered
=
False
try
:
try
:
yield
self
.
_issuer
.
_ensure_registered
()
await
self
.
_issuer
.
_ensure_registered
()
except
Exception
:
except
Exception
:
logger
.
error
(
ACME_REGISTER_FAIL_ERROR
)
logger
.
error
(
ACME_REGISTER_FAIL_ERROR
)
raise
raise
@defer.inlineCallbacks
async
def
provision_certificate
(
self
):
def
provision_certificate
(
self
):
logger
.
warning
(
"
Reprovisioning %s
"
,
self
.
_acme_domain
)
logger
.
warning
(
"
Reprovisioning %s
"
,
self
.
_acme_domain
)
try
:
try
:
yield
self
.
_issuer
.
issue_cert
(
self
.
_acme_domain
)
await
self
.
_issuer
.
issue_cert
(
self
.
_acme_domain
)
except
Exception
:
except
Exception
:
logger
.
exception
(
"
Fail!
"
)
logger
.
exception
(
"
Fail!
"
)
raise
raise
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment