2022-05-20 21:05:38 +02:00
|
|
|
---
|
|
|
|
title: ACME.SH
|
2022-11-19 15:25:20 +01:00
|
|
|
visible: true
|
2022-05-20 21:05:38 +02:00
|
|
|
---
|
|
|
|
|
2022-06-06 18:34:54 +02:00
|
|
|
[toc]
|
2022-12-16 11:46:32 +01:00
|
|
|
|
2022-05-20 21:05:38 +02:00
|
|
|
## Getting ACME.SH
|
2022-12-16 11:46:32 +01:00
|
|
|
|
|
|
|
```sh
|
2023-02-19 15:15:17 +01:00
|
|
|
git clone https://github.com/acmesh-official/acme.sh.git
|
|
|
|
cd ./acme.sh
|
|
|
|
./acme.sh --install -m my@example.com
|
2022-05-20 21:05:38 +02:00
|
|
|
```
|
|
|
|
|
|
|
|
## First time ZeroSSL registration
|
2022-12-16 11:46:32 +01:00
|
|
|
|
2023-02-19 15:15:17 +01:00
|
|
|
```sh
|
|
|
|
(path to)/acme.sh --register-account -m (email)
|
|
|
|
```
|
2022-05-20 21:05:38 +02:00
|
|
|
|
|
|
|
## Issue new certificate
|
2022-12-16 11:46:32 +01:00
|
|
|
|
2023-02-19 15:15:17 +01:00
|
|
|
Needs root to start a server on port 80
|
|
|
|
|
|
|
|
```sh
|
|
|
|
(path to)/acme.sh --issue --standalone -d (url)
|
|
|
|
```
|
2022-05-20 21:05:38 +02:00
|
|
|
|
|
|
|
## Issue new certificate with DNS API
|
2022-12-16 11:46:32 +01:00
|
|
|
|
2022-05-20 21:05:38 +02:00
|
|
|
> [Official Documentation](https://github.com/acmesh-official/acme.sh/wiki/dnsapi)
|
|
|
|
|
|
|
|
### Gandi
|
|
|
|
|
2023-02-19 15:15:17 +01:00
|
|
|
```sh
|
|
|
|
export GANDI_LIVEDNS_KEY="(api key)"
|
|
|
|
```
|
2022-12-16 11:46:32 +01:00
|
|
|
|
2023-02-19 15:15:17 +01:00
|
|
|
```sh
|
|
|
|
(path to)/acme.sh --issue --dns dns_gandi_livedns -d (domain)
|
|
|
|
```
|
2022-05-20 21:05:38 +02:00
|
|
|
|
|
|
|
## Install certificate
|
|
|
|
|
2022-12-16 11:46:32 +01:00
|
|
|
Make sure to create the `/etc/acme-sh/(url)` directory
|
|
|
|
|
|
|
|
```sh
|
2022-09-11 17:36:46 +02:00
|
|
|
$ export url=woodpecker.exu.li \
|
|
|
|
&& mkdir -p /etc/acme-sh/{$url} \
|
|
|
|
&& .acme.sh/acme.sh --install-cert -d $url \
|
2022-05-20 21:05:38 +02:00
|
|
|
--key-file /etc/acme-sh/{$url}/key.pem \
|
|
|
|
--fullchain-file /etc/acme-sh/{$url}/cert.pem \
|
|
|
|
--reloadcmd "sudo systemctl restart nginx"
|
|
|
|
```
|
|
|
|
|
|
|
|
## Systems Service & Timer
|
2022-12-16 11:46:32 +01:00
|
|
|
|
|
|
|
`/etc/systemd/system/acme-sh.service`
|
|
|
|
|
|
|
|
```systemd
|
2022-05-20 21:05:38 +02:00
|
|
|
[Unit]
|
|
|
|
Description=Renew certificates using acme.sh
|
|
|
|
After=network-online.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
|
|
|
ExecStart=(path to acme.sh) --cron --home (path to acme folder)
|
|
|
|
User=wiki
|
|
|
|
|
|
|
|
SuccessExitStatus=0 2
|
|
|
|
```
|
|
|
|
|
2022-12-16 11:46:32 +01:00
|
|
|
`/etc/systemd/system/acme.timer`
|
|
|
|
|
|
|
|
```systemd
|
2022-05-20 21:05:38 +02:00
|
|
|
[Unit]
|
|
|
|
Description=Daily renewal of certificates
|
|
|
|
|
|
|
|
[Timer]
|
|
|
|
OnCalendar=daily
|
|
|
|
RandomizedDelaySec=1h
|
|
|
|
Persistent=true
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=timers.target
|
|
|
|
```
|
|
|
|
|
2023-02-19 15:15:17 +01:00
|
|
|
Enable timer
|
|
|
|
|
|
|
|
```sh
|
|
|
|
systemctl enable --now acme-sh.timer
|
|
|
|
```
|