mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
acme: add certbot dns script
Add a script to use as a certbot hook for satisfying the dns-01 challenge. It will be used during testing, and may be useful or instructive for users of FreeIPA. It is installed as part of the freeipa-client package under /usr/libexec/ipa/acme. Future ACME-related scripts can be added in the same place. Part of: https://pagure.io/freeipa/issue/4751 Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
parent
e976dde8e1
commit
a83eaa8b6d
@ -47,6 +47,11 @@ sbin_SCRIPTS = \
|
|||||||
ipa-epn \
|
ipa-epn \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
|
appdir = $(libexecdir)/ipa/acme
|
||||||
|
nodist_app_SCRIPTS = \
|
||||||
|
certbot-dns-ipa \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
ipa_getkeytab_SOURCES = \
|
ipa_getkeytab_SOURCES = \
|
||||||
ipa-getkeytab.c \
|
ipa-getkeytab.c \
|
||||||
ipa-client-common.c \
|
ipa-client-common.c \
|
||||||
@ -111,6 +116,7 @@ EXTRA_DIST = \
|
|||||||
ipa-client-install.in \
|
ipa-client-install.in \
|
||||||
ipa-client-samba.in \
|
ipa-client-samba.in \
|
||||||
ipa-epn.in \
|
ipa-epn.in \
|
||||||
|
certbot-dns-ipa.in \
|
||||||
$(NULL)
|
$(NULL)
|
||||||
|
|
||||||
install-data-hook:
|
install-data-hook:
|
||||||
@ -119,6 +125,9 @@ install-data-hook:
|
|||||||
$(INSTALL) -d -m 755 $(DESTDIR)$(localstatedir)/lib/ipa-client/sysrestore
|
$(INSTALL) -d -m 755 $(DESTDIR)$(localstatedir)/lib/ipa-client/sysrestore
|
||||||
|
|
||||||
|
|
||||||
PYTHON_SHEBANG = $(sbin_SCRIPTS)
|
PYTHON_SHEBANG = \
|
||||||
|
$(sbin_SCRIPTS) \
|
||||||
|
$(nodist_app_SCRIPTS) \
|
||||||
|
$(NULL)
|
||||||
|
|
||||||
include $(top_srcdir)/Makefile.pythonscripts.am
|
include $(top_srcdir)/Makefile.pythonscripts.am
|
||||||
|
50
client/certbot-dns-ipa.in
Executable file
50
client/certbot-dns-ipa.in
Executable file
@ -0,0 +1,50 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
#
|
||||||
|
# Copyright (C) 2020 FreeIPA Contributors see COPYING for license
|
||||||
|
#
|
||||||
|
|
||||||
|
"""
|
||||||
|
This script can be used with Certbot to satisfy dns-01 challenges.
|
||||||
|
FreeIPA integrated DNS is required.
|
||||||
|
|
||||||
|
This script can be used for both --manual-auth-hook and
|
||||||
|
--manual-cleanup-hook. It not intended to be used in other
|
||||||
|
contexts.
|
||||||
|
|
||||||
|
Kerberos credentials are required. The principal must have
|
||||||
|
permission to add and delete DNS records via the dnsrecord_add and
|
||||||
|
dnsrecord_del commands.
|
||||||
|
|
||||||
|
"""
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from dns import resolver
|
||||||
|
from ipalib import api, errors
|
||||||
|
from ipapython import dnsutil
|
||||||
|
|
||||||
|
try:
|
||||||
|
certbot_domain = os.environ['CERTBOT_DOMAIN']
|
||||||
|
certbot_validation = os.environ['CERTBOT_VALIDATION']
|
||||||
|
except KeyError:
|
||||||
|
sys.exit("Missing Certbot environment variables.")
|
||||||
|
|
||||||
|
if 'CERTBOT_AUTH_OUTPUT' in os.environ:
|
||||||
|
command = 'dnsrecord_del'
|
||||||
|
else:
|
||||||
|
command = 'dnsrecord_add'
|
||||||
|
|
||||||
|
validation_domain = f'_acme-challenge.{certbot_domain}'
|
||||||
|
fqdn = dnsutil.DNSName(validation_domain).make_absolute()
|
||||||
|
zone = dnsutil.DNSName(resolver.zone_for_name(fqdn))
|
||||||
|
name = fqdn.relativize(zone)
|
||||||
|
|
||||||
|
try:
|
||||||
|
api.bootstrap(context='cli')
|
||||||
|
api.finalize()
|
||||||
|
api.Backend.rpcclient.connect()
|
||||||
|
except errors.CCacheError as e:
|
||||||
|
sys.exit(e)
|
||||||
|
|
||||||
|
api.Command[command](zone, name, txtrecord=[certbot_validation], dnsttl=60)
|
@ -1197,7 +1197,6 @@ fi
|
|||||||
%{_sbindir}/ipa-acme-manage
|
%{_sbindir}/ipa-acme-manage
|
||||||
%{_libexecdir}/certmonger/dogtag-ipa-ca-renew-agent-submit
|
%{_libexecdir}/certmonger/dogtag-ipa-ca-renew-agent-submit
|
||||||
%{_libexecdir}/certmonger/ipa-server-guard
|
%{_libexecdir}/certmonger/ipa-server-guard
|
||||||
%dir %{_libexecdir}/ipa
|
|
||||||
%{_libexecdir}/ipa/ipa-custodia
|
%{_libexecdir}/ipa/ipa-custodia
|
||||||
%{_libexecdir}/ipa/ipa-custodia-check
|
%{_libexecdir}/ipa/ipa-custodia-check
|
||||||
%{_libexecdir}/ipa/ipa-httpd-kdcproxy
|
%{_libexecdir}/ipa/ipa-httpd-kdcproxy
|
||||||
@ -1408,6 +1407,8 @@ fi
|
|||||||
%{_mandir}/man1/ipa-client-automount.1*
|
%{_mandir}/man1/ipa-client-automount.1*
|
||||||
%{_mandir}/man1/ipa-certupdate.1*
|
%{_mandir}/man1/ipa-certupdate.1*
|
||||||
%{_mandir}/man1/ipa-join.1*
|
%{_mandir}/man1/ipa-join.1*
|
||||||
|
%dir %{_libexecdir}/ipa/acme
|
||||||
|
%{_libexecdir}/ipa/acme/certbot-dns-ipa
|
||||||
|
|
||||||
%files client-samba
|
%files client-samba
|
||||||
%doc README.md Contributors.txt
|
%doc README.md Contributors.txt
|
||||||
@ -1490,6 +1491,7 @@ fi
|
|||||||
%doc README.md Contributors.txt
|
%doc README.md Contributors.txt
|
||||||
%license COPYING
|
%license COPYING
|
||||||
%dir %{_usr}/share/ipa
|
%dir %{_usr}/share/ipa
|
||||||
|
%dir %{_libexecdir}/ipa
|
||||||
|
|
||||||
|
|
||||||
%files -n python3-ipalib
|
%files -n python3-ipalib
|
||||||
|
Loading…
Reference in New Issue
Block a user