Blob Blame Raw

%if 0%{?rhel} >= 5 && 0%{?rhel} < 7
%global use_systemd 0
%global use_systemd 1

%if 0%{?fedora}
# Explicity require python3 on Fedora to help track which packages 
# no longer need python2.
%global use_python3 1
%global use_python3 0

Name:		acme-tiny
Version:	4.0.4
Release:	3%{?dist}
Summary:	Tiny auditable script to issue, renew Let's Encrypt certificates

License:	MIT
Source3:	acme.conf
Source4:	lets-encrypt-x3-cross-signed.pem
Source5:	acme-tiny.cron
Source6:	acme-tiny.timer
Source7:	acme-tiny.service
# Fetch and include intermediate cert(s), too.
Patch0:		acme-tiny-chain.patch
# Python3 broke getallmatchingheaders() and the fix breaks python2
Patch1:		acme-tiny-chain2.patch

Requires(pre): shadow-utils
%if %{use_systemd}
# systemd macros are not defined unless systemd is present
BuildRequires: systemd
Requires:	cronie
Requires: %{name}-core = %{version}-%{release}
BuildArch:	noarch
%if 0%{?fedora}
Suggests: httpd, mod_ssl, nginx
Enhances: httpd, mod_ssl, nginx

This is a tiny, auditable script that you can throw on your server to issue and
renew Let's Encrypt certificates. Since it has to be run on your server and
have access to your private Let's Encrypt account key, I tried to make it as
tiny as possible (currently less than 200 lines). The only prerequisites are
python and openssl.  

Well, that and a web server - but then you only need this with a web server.
This package adds a simple directory layout and timer service that runs
acme_tiny on installed CSRs as the acme user for privilege separation.

%package core
Summary: core python module of acme-tiny
Requires:	openssl
%if 0%{?rhel} >= 5 && 0%{?rhel} < 7
# EL6 uses python2.6, which does not include argparse
Requires:	python-argparse
BuildArch: noarch

%description core
Includes only the core script and its dependencies.
Alternate frameworks that use can install this to avoid pulling in
unneeded packages.

%setup -q -n %{name}-%{version}
cp -p %{SOURCE1} %{SOURCE2} %{SOURCE8} .
sed -i.orig -e '1,1 s,^.*python$,#!/usr/bin/python,'
%if %{use_python3}
#patch0 -p1 -b .chain
sed -i.old -e '1,1 s/python$/python3/' *.py
#patch1 -p1 -b .chain2


mkdir -p %{buildroot}/var/www/challenges
mkdir -p %{buildroot}%{_sysconfdir}/httpd/conf.d
mkdir -p %{buildroot}%{_sbindir}
mkdir -p %{buildroot}%{_libexecdir}/%{name}
mkdir -p %{buildroot}%{_sharedstatedir}/acme/{private,csr,certs}
chmod 0700 %{buildroot}%{_sharedstatedir}/acme/private

install -m 0755 %{buildroot}%{_libexecdir}/%{name}/sign
install -m 0755 %{buildroot}%{_sbindir}/acme_tiny
ln -sf acme_tiny %{buildroot}%{_sbindir}/acme-tiny
ln -sf %{_libexecdir}/%{name}/sign %{buildroot}%{_sbindir}/acme-tiny-sign
install -m 0755 %{buildroot}%{_sbindir}/cert-check
install -m 0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/httpd/conf.d
install -m 0644 %{SOURCE4} %{buildroot}%{_sharedstatedir}/acme
%if %{use_systemd}
mkdir -p %{buildroot}%{_unitdir}
install -pm 644	 %{SOURCE6} %{buildroot}%{_unitdir}
install -pm 644	 %{SOURCE7} %{buildroot}%{_unitdir}
mkdir -p %{buildroot}%{_sysconfdir}/cron.d
install -m 0644 %{SOURCE5} %{buildroot}%{_sysconfdir}/cron.d/acme-tiny

getent group acme > /dev/null || groupadd -r acme
getent passwd acme > /dev/null || /usr/sbin/useradd -g acme \
	-c "Tiny Auditable ACME Client" \
	-r -d %{_sharedstatedir}/acme -s /sbin/nologin acme
exit 0

%if %{use_systemd}

%systemd_post acme-tiny.service acme-tiny.timer

%systemd_postun_with_restart acme-tiny.service acme-tiny.timer

%systemd_preun acme-tiny.service acme-tiny.timer


%{!?_licensedir:%global license %%doc}
%license LICENSE
%attr(0755,acme,acme) /var/www/challenges
%attr(-,acme,acme) %{_sharedstatedir}/acme
%config(noreplace) %{_sysconfdir}/httpd/conf.d/acme.conf
%if %{use_systemd}
%config(noreplace) %{_sysconfdir}/cron.d/acme-tiny

%files core
%license LICENSE

* Thu Jan 31 2019 Fedora Release Engineering <> - 4.0.4-3
- Rebuilt for

* Thu Jul 12 2018 Fedora Release Engineering <> - 4.0.4-2
- Rebuilt for

* Tue May 22 2018 Stuart D. Gathman <> 4.0.4-1
- Official upstream release! BZ#1560531
- Move to acme-tiny-core subpackage BZ#1438181

* Wed Feb 07 2018 Fedora Release Engineering <> - 0.2-4.20170516gitaf025f5
- Rebuilt for

* Wed Nov 22 2017 Stuart D. Gathman <> 0.2-3.20170616gitaf025f5
- BZ#1507333 EL6 missing python-argparse dependency
- BZ#1515781 Agreement updated.
- BZ#1409345 Unwritable certs silently skipped

* Wed Jul 26 2017 Fedora Release Engineering <> - 0.2-2.20170516gitaf025f5
- Rebuilt for

* Thu Jul  6 2017 Stuart D. Gathman <> 0.2-1.20170616gitaf025f5
- BZ#1468045 Update to new upstream version
- BZ#1409686 Message.getallmatchingheaders() is broken in python3.

* Fri Feb 10 2017 Fedora Release Engineering <> - 0.1-12.20160810git5a7b4e7
- Rebuilt for

* Mon Dec 19 2016 Miro HronĨok <> - 0.1-11.20160810git5a7b4e7
- Rebuild for Python 3.6

* Mon Aug 22 2016 Stuart D. Gathman <> 0.1-10.20160810git5a7b4e7
- Fix cert writable check in sign script
- More tips in

* Mon Aug 22 2016 Stuart D. Gathman <> 0.1-9.20160810git5a7b4e7
- Use %%{systemd_requires}
- Remove unneeded cronie, python dependencies
- Add acme-tiny.timer to systemd scriptlets
- Add
- acme_tiny: Fix --chain patch for python2.6 (el6)
- acme_tiny: Suppress traceback on error

* Sun Aug 21 2016 Stuart D. Gathman <> 0.1-8
- Add use_systemd flag to use systemd timer and enable on Fedora and epel7
- Enable use_python3 flag for Fedora (but not epel7).

* Sat Aug 20 2016 Stuart D. Gathman <> 0.1-7
- sign: Actually use the new --chain flag
- cron: Make days to expiration explicit
- spec: Set file modes with install
- acme.conf: mark as config

* Fri Aug 19 2016 Stuart D. Gathman <> 0.1-6
- Python3 fixes for cert-check
- acme-tiny: Update patch to leave default behavior unchanged
- make /var/lib/acme readable by all except private

* Thu Aug 11 2016 Stuart D. Gathman <> 0.1-5
- sign: Use tmp output to avoid wiping existing cert on error
- acme_tiny: get intermediate cert from acme protocol

* Thu Aug 11 2016 Stuart D. Gathman <> 0.1-4
- Fix path of acme_tiny and make days explicit in sign script
- Add crontab

* Wed Aug 10 2016 Stuart D. Gathman <> 0.1-3
- Add global acme httpd conf
- Append intermediate certs, add current lets-encrypt intermediate cert

* Tue Aug  9 2016 Stuart D. Gathman <> 0.1-2
- add private, csr, certs directories
- add sign script suitable for cron

* Mon Aug  8 2016 Stuart D. Gathman <> 0.1-1
- Initial RPM