Commit 9c6efad5 authored by Sunil Mohan Adapa's avatar Sunil Mohan Adapa Committed by Joseph Nuthalapati

letsencrypt: Implement re-obtain separately

Signed-off-by: Sunil Mohan Adapa's avatarSunil Mohan Adapa <>
Reviewed-by: Joseph Nuthalapati's avatarJoseph Nuthalapati <>
parent 8cae72c4
......@@ -119,10 +119,21 @@ def diagnose():
def certificate_obtain(domain):
"""Obtain a certificate for a domain and notify handlers."""
actions.superuser_run('letsencrypt', ['obtain', '--domain', domain])
components.on_certificate_event('obtained', [domain], None)
# Don't trigger an obtained event. Obtaining a certificate freshly also
# leads to a renewal (deploy) event from Let's Encrypt. There is no easy
# way to distinguish if the event is an initial event or a renewal event.
def certificate_reobtain(domain):
"""Re-obtain a certificate for a domain and notify handlers.
Don't trigger an obtained event. Re-obtaining a certificate also leads to a
renewal (deploy) event from Let's Encrypt. Further, this event is not sent
when obtaining the certificate for the first time. There is no easy way to
distinguish if a renewal event is trigger because of obtain or because of
re-obtain. Hence, handle re-obtain differently from obtain and don't
trigger obtain event (LE will trigger a renewal event).
actions.superuser_run('letsencrypt', ['obtain', '--domain', domain])
def certificate_revoke(domain):
......@@ -94,7 +94,7 @@
{% if domain_status.certificate_available %}
<form class="form form-inline" method="post"
action="{% url 'letsencrypt:obtain' domain %}">
action="{% url 'letsencrypt:re-obtain' domain %}">
{% csrf_token %}
<button class="btn btn-sm btn-default" type="submit">
{% trans "Re-obtain" %}</button>
......@@ -24,10 +24,12 @@ from . import views
urlpatterns = [
url(r'^sys/letsencrypt/$', views.index, name='index'),
url(r'^sys/letsencrypt/revoke/(?P<domain>[^/]+)/$', views.revoke,
url(r'^sys/letsencrypt/obtain/(?P<domain>[^/]+)/$', views.obtain,
url(r'^sys/letsencrypt/re-obtain/(?P<domain>[^/]+)/$', views.reobtain,
url(r'^sys/letsencrypt/revoke/(?P<domain>[^/]+)/$', views.revoke,
url(r'^sys/letsencrypt/delete/(?P<domain>[^/]+)/$', views.delete,
......@@ -82,6 +82,23 @@ def obtain(request, domain):
return redirect(reverse_lazy('letsencrypt:index'))
def reobtain(request, domain):
"""Re-obtain a certificate for a given domain."""
_('Certificate successfully obtained for domain {domain}').format(
except ActionError as exception:
_('Failed to obtain certificate for domain {domain}: {error}').
format(domain=domain, error=exception.args[2]))
return redirect(reverse_lazy('letsencrypt:index'))
def delete(request, domain):
"""Delete a certificate for a given domain, and cleanup renewal config."""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment