... | @@ -88,23 +88,37 @@ Wir nutzen `acme_tiny` für Let's Encrypt. Zertifikate sind in `/etc/ssl/letsenc |
... | @@ -88,23 +88,37 @@ Wir nutzen `acme_tiny` für Let's Encrypt. Zertifikate sind in `/etc/ssl/letsenc |
|
|
|
|
|
[Ausführliche Dokumentation auf GitHub](https://github.com/drdaeman/acme-tiny/blob/f995b09b67498ef6fc538867eeeb63643cba5702/README.md)
|
|
[Ausführliche Dokumentation auf GitHub](https://github.com/drdaeman/acme-tiny/blob/f995b09b67498ef6fc538867eeeb63643cba5702/README.md)
|
|
|
|
|
|
|
|
## Private Key für Domain erstellen (RSA)
|
|
|
|
|
|
```
|
|
```
|
|
# cd /etc/ssl/letsencrypt
|
|
# cd /etc/ssl/letsencrypt
|
|
// Private Key für Domain erstellen (RSA)
|
|
|
|
# openssl genrsa 4096 > subdomain.bau-ha.us.key
|
|
# openssl genrsa 4096 > subdomain.bau-ha.us.key
|
|
|
|
```
|
|
|
|
|
|
|
|
## CSR Request erstellen
|
|
|
|
|
|
// CSR Request erstellen
|
|
```
|
|
# openssl req -new -sha256 -key subdomain.bau-ha.us.key -subj "/CN=subdomain.bau-ha.us" > subdomain.bau-ha.us.csr
|
|
# openssl req -new -sha256 \
|
|
|
|
-key subdomain.bau-ha.us.key \
|
|
|
|
-subj "/CN=subdomain.bau-ha.us" \
|
|
|
|
> subdomain.bau-ha.us.csr
|
|
|
|
|
|
// mehrere Domains in einem Zertikat (www.meinedomain.de, meinedomain.de, foobar.meinedomain.de..)
|
|
// mehrere Domains in einem Zertikat
|
|
# openssl req -new -sha256 -key subdomain.bau-ha.us.key \
|
|
// (www.meinedomain.de, meinedomain.de, foobar.meinedomain.de..)
|
|
|
|
# openssl req -new -sha256 \
|
|
|
|
-key subdomain.bau-ha.us.key \
|
|
-subj "/" -reqexts SAN \
|
|
-subj "/" -reqexts SAN \
|
|
-config <(cat /etc/ssl/openssl.cnf } \
|
|
-config <(cat /etc/ssl/openssl.cnf } \
|
|
<(printf "[SAN]\nsubjectAltName=DNS:subdomain.bau-ha.us,DNS:www.subdomain.de")) \
|
|
<(printf "[SAN]\nsubjectAltName=DNS:subdomain.bau-ha.us,DNS:www.subdomain.de")) \
|
|
> subdomain.bau-ha.us.csr
|
|
> subdomain.bau-ha.us.csr
|
|
|
|
|
|
// Challenges Verzeichnis in nginx Konfiguration einbinden
|
|
```
|
|
// /etc/nginx/sites-available/subdomain.bau-ha.us
|
|
|
|
|
|
|
|
|
|
## Challenges Verzeichnis in nginx Konfiguration einbinden
|
|
|
|
|
|
|
|
```
|
|
|
|
# /etc/nginx/sites-available/subdomain.bau-ha.us
|
|
server {
|
|
server {
|
|
listen 80;
|
|
listen 80;
|
|
server_name subdomain.bau-ha.us foobarbaz.subdomain.bau-ha.us;
|
|
server_name subdomain.bau-ha.us foobarbaz.subdomain.bau-ha.us;
|
... | @@ -118,15 +132,17 @@ server { |
... | @@ -118,15 +132,17 @@ server { |
|
return 301 https://$host$request_uri;
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
```
|
|
|
|
|
|
// Zertifikat von Let's Encrypt unterschreiben lassen.
|
|
## Zertifikat von Let's Encrypt unterschreiben lassen.
|
|
|
|
|
|
// Automatisch
|
|
### Per Script
|
|
|
|
|
|
# /etc/letsencrypt/ssl/renew.sh subdomain.bau-ha.us
|
|
# /etc/letsencrypt/ssl/renew.sh subdomain.bau-ha.us
|
|
|
|
|
|
// Manuell
|
|
### Manuell
|
|
|
|
|
|
|
|
```
|
|
# acme_tiny --account-key ./account.key --csr ./subdomain.bau-ha.us.csr --acme-dir /var/www/challenges/ > ./subdomain.bau-ha.us.crt
|
|
# acme_tiny --account-key ./account.key --csr ./subdomain.bau-ha.us.csr --acme-dir /var/www/challenges/ > ./subdomain.bau-ha.us.crt
|
|
|
|
|
|
// Let's Encrypt Intermediate Zertifikat hinzufügen
|
|
// Let's Encrypt Intermediate Zertifikat hinzufügen
|
... | @@ -134,11 +150,11 @@ server { |
... | @@ -134,11 +150,11 @@ server { |
|
# cat subdomain.bau-ha.us.crt /tmp/intermediate.pem > subdomain.bau-ha.us.chained.pem
|
|
# cat subdomain.bau-ha.us.crt /tmp/intermediate.pem > subdomain.bau-ha.us.chained.pem
|
|
```
|
|
```
|
|
|
|
|
|
|
|
## nginx
|
|
|
|
|
|
Jetzt kann man die Zertifikate in den nginx Virtualhost einbinden:
|
|
Jetzt kann man die Zertifikate in den nginx Virtualhost einbinden:
|
|
|
|
|
|
``
|
|
```
|
|
server {
|
|
server {
|
|
listen 443 ssl http2;
|
|
listen 443 ssl http2;
|
|
server_name subdomain.bau-ha.us;
|
|
server_name subdomain.bau-ha.us;
|
... | @@ -154,8 +170,10 @@ server { |
... | @@ -154,8 +170,10 @@ server { |
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
|
|
|
|
|
|
...
|
|
...
|
|
|
|
|
|
}
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
## Erneuerung mit cron
|
|
|
|
|
|
Jetzt noch die `crontab` für das monatliche erneuern der Zertifikate:
|
|
Jetzt noch die `crontab` für das monatliche erneuern der Zertifikate:
|
|
|
|
|
... | | ... | |