Commit 965f7101 authored by Sunil Mohan Adapa's avatar Sunil Mohan Adapa Committed by Joseph Nuthalapati

letsencrypt: Implement DBus service for renewal notifications

Signed-off-by: Sunil Mohan Adapa's avatarSunil Mohan Adapa <>
Reviewed-by: Joseph Nuthalapati's avatarJoseph Nuthalapati <>
parent 50c0858d
......@@ -100,6 +100,10 @@ class DBusServer():
self.package_handler = PackageHandler()
from plinth.modules.letsencrypt.dbus import LetsEncrypt
lets_encrypt = LetsEncrypt()
def on_name_acquired(_connection, name):
"""Callback when service name on D-Bus has been acquired."""
# This file is part of FreedomBox.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <>.
Expose API over D-Bus to receive renewal notifications.
import logging
from plinth.utils import import_from_gi
gio = import_from_gi('Gio', '2.0')
logger = logging.getLogger(__name__)
class LetsEncrypt:
"""D-Bus service to listen for Let's Encrypt renewal notifications."""
introspection_xml = '''
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN"
<node name="/org/freedombox/Service/LetsEncrypt">
<interface name="org.freedombox.Service.LetsEncrypt">
<method name="DeployHook">
<arg name="renewed_domains" type="s" direction="in"/>
<arg name="renewed_lineage" type="s" direction="in"/>
def register(self, connection):
"""Register the object in D-Bus connection."""
introspection_data = gio.DBusNodeInfo.new_for_xml(
interface_info = gio.DBusNodeInfo.lookup_interface(
introspection_data, 'org.freedombox.Service.LetsEncrypt')
interface_info, self.on_method_call, None,
def on_method_call(self, _connection, _sender, _object_path,
_interface_name, method_name, parameters, invocation):
"""Handle method being called.
No need to check all the incoming parameters as D-Bus will validate all
the incoming parameters using introspection data.
if method_name == 'DeployHook':
self._on_deploy_hook(parameters[0], parameters[1])
def _on_deploy_hook(renewed_domains, renewed_lineage):
"""Run renewal hooks for each app.
Don't run this a new thread here because
component.on_certificate_event() creates one anyway.
"""'LE certificate renewed (deployed): %s, %s.',
renewed_domains, renewed_lineage)
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