1Host *.home.example.com
2 ProxyJump home.example.com
1==================================================================
2Package Arch Version Repo Size
3==================================================================
4Installing:
5certbot noarch 2.5.0-1.fc37 updates 17 k
6Installing dependencies:
7dbus aarch64 1:1.14.6-1.fc37 updates 7.7 k
8dbus-broker aarch64 33-1.fc37 updates 168 k
9dbus-common noarch 1:1.14.6-1.fc37 updates 15 k
10--------------------8<--------------------------8<------------------
11device-mapper aarch64 1.02.175-9.fc37 fedora 136 k
12device-mapper-libs aarch64 1.02.175-9.fc37 fedora 169 k
13systemd-networkd aarch64 251.14-2.fc37 updates 571 k
14systemd-resolved aarch64 251.14-2.fc37 updates 262 k
15
16Transaction Summary
17==================================================================
18Install 39 Packages
http://<YOUR_DOMAIN>/.well-known/acme-challenge/<TOKEN>
--manual-auth-hook
passes two ENV Variables:
1#!/bin/sh
2
3KEY="SomeKey"
4SECRET="SomeSecret"
5
6APISITE="api.godaddy.com"
7
8BASEDOMAIN=`echo ${CERTBOT_DOMAIN} | awk -F. '{OFS="."; print $(NF-1),$(NF)}'`
9SUBDOMAIN=`echo ${CERTBOT_DOMAIN} | sed -e 's/'${BASEDOMAIN}'//' -e 's/\.$//'`
10
11if [ -z ${SUBDOMAIN} ] ; then
12 DNSRECORD="_acme-challenge"
13else
14 DNSRECORD="_acme-challenge.${SUBDOMAIN}"
15fi
16
17UpDateDNS(${BASEDOMIN} ${DNSRECORD} ${CERTBOT_VALIDATION})
1certbot certonly --manual \
2-d *.example.com \
3-d example.com \
4--preferred-challenges dns \
5--manual-auth-hook /etc/letsencrypt/CertBotGoDaddyAuthHook.sh
Running certbot certificates command
1- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
2Found the following certs:
3 Certificate Name: example.com
4 Serial Number: 4ed92b171a54e8ef6ecc98b8c9d13dd08b8
5 Key Type: RSA
6 Domains: *.example.com example.com
7 Expiry Date: 2023-08-18 12:23:26+00:00 (VALID: 89 days)
8 Certificate Path: /etc/letsencrypt/live/example.com/fullchain.pem
9 Private Key Path: /etc/letsencrypt/live/example.com/privkey.pem
10 Certificate Name: test.example.com
11 Serial Number: fa4806d9253983a3cbf5cbe0df606de4483d
12 Key Type: RSA
13 Domains: *.test.example.com
14 Expiry Date: 2023-08-18 12:51:05+00:00 (INVALID: TEST_CERT)
15 Certificate Path: /etc/letsencrypt/live/test.example.com/fullchain.pem
16 Private Key Path: /etc/letsencrypt/live/test.example.com/privkey.pem
17- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
/etc/letsencrypt/renewal/example.com.conf
1# renew_before_expiry = 30 days
2version = 1.21.0
3archive_dir = /etc/letsencrypt/archive/example.com
4cert = /etc/letsencrypt/live/example.com/cert.pem
5privkey = /etc/letsencrypt/live/example.com/privkey.pem
6chain = /etc/letsencrypt/live/example.com/chain.pem
7fullchain = /etc/letsencrypt/live/example.com/fullchain.pem
8
9# Options used in the renewal process
10[renewalparams]
11account = 4a6d9352e2fc12db24d8d48208528151
12pref_challs = dns-01,
13authenticator = manual
14manual_auth_hook = /etc/letsencrypt/CertBotGoDaddyAuthHook.sh
15server = https://acme-v02.api.letsencrypt.org/directory
1ACMEURL="https://acme-staging-v02.api.letsencrypt.org/directory"
2certbot --server ${ACMEURL} -d blah.example.com --manual
Stage: (also can be done by --test-cert)
Three use cases for Ansible to solve
Multiple certs that land into a single directory
1loadbalancers:
2 hosts:
3 loadbalancer1.home.example.com:
4 domains:
5 - example.com
6 - app.example.com
7 - home.example.com
8 certdir: /etc/nginx/certs
9 loadbalancer2.home.example.com:
10 domains:
11 - example.com
12 - app.example.com
13 - home.example.com
14 certdir: /etc/nginx/certs
Because every application seems to put cert files into seeming random places
1appcerts:
2 hosts:
3 nessus.home.example.com:
4 domain: home.example.com
5 certfile: /opt/nessus/com/nessus/CA/servercert.pem
6 keyfile: /opt/nessus/var/nessus/CA/serverkey.pem
7 service: nessusd
8 haproxy:
9 enabled: true
10 cert_dest: /etc/haproxy/haproxy.pem
11 logs.home.example.com:
12 domain: home.example.com
13 certfile: /opt/splunk/etc/auth/splunkweb/cert.pem
14 keyfile: /opt/splunk/etc/auth/splunkweb/privkey.pem
15 service: splunk
16 haproxy:
17 enabled: true
18 cert_dest: /etc/haproxy/haproxy.pem
19 media.home.example.com:
20 domain: example.com
21 certfile: /etc/pki/tls/certs/example.crt
22 keyfile: /etc/pki/tls/certs/example.key
23 service: httpd
Uses inventory
1- name: Update App Certs
2 hosts: appcerts
3 become: true
4 gather_facts: false
5
6 tasks:
7 - name: Copy {{ domain }} cert to Host
8 ansible.builtin.copy:
9 src: /etc/letsencrypt/live/{{ domain }}/fullchain.pem
10 dest: "{{ certfile }}"
11 notify: Restart Service
12
13 - name: Copy {{ domain }} key to Host
14 ansible.builtin.copy:
15 src: /etc/letsencrypt/live/{{ domain }}/privkey.pem
16 dest: "{{ keyfile }}"
17 notify: Restart Service
18
19 - name: Create haproxy cert if enabled
20 ansible.builtin.assemble:
21 src: /etc/letsencrypt/live/{{ domain }}
22 dest: "{{ haproxy.cert_dest }}"
23 owner: "{{ haproxy.owner | default('root') }}"
24 group: "{{ haproxy.group | default('root') }}"
25 mode: "{{ haproxy.mode | default('0600') }}"
26 regexp: '(fullchain|privkey)\.pem$'
27 remote_src: false
28 when: (haproxy is defined) and (haproxy.enabled|bool == true)
29 notify: Restart Haproxy
30
31 handlers:
32 - name: Restart Service
33 service:
34 name: "{{ service }}"
35 state: restarted
36
37 - name: Restart Haproxy
38 service:
39 name: haproxy.service
40 state: restarted
41
42- name: Update Loadbalancer Certs
43 hosts: loadbalancers
44 gather_facts: false
45
46 vars:
47 service: nginx
48
49 tasks:
50 - name: Copy Cert to Host
51 ansible.builtin.copy:
52 src: /etc/letsencrypt/live/{{ item }}/fullchain.pem
53 dest: "{{ certdir }}/{{ item }}.crt"
54 notify: Restart Service
55 with_items: "{{ domains }}"
56
57 - name: Copy Chain Cert to Host
58 ansible.builtin.copy:
59 src: /etc/letsencrypt/live/{{ item }}/chain.pem
60 dest: "{{ certdir }}/{{ item }}.int"
61 notify: Restart Service
62 with_items: "{{ domains }}"
63
64 - name: Copy Private Key to Host
65 ansible.builtin.copy:
66 src: /etc/letsencrypt/live/{{ item }}/privkey.pem
67 dest: "{{ certdir }}/{{ item }}.key"
68 notify: Restart Service
69 with_items: "{{ domains }}"
70
71 handlers:
72 - name: Restart Service
73 service:
74 name: "{{ service }}"
75 state: restarted
1Create New Cert:
2ACMEURL="https://acme-v02.api.letsencrypt.org/directory"
3certbot --server ${ACMEURL} -d blah.example.com --manual certonly
4certbot --server ${ACMEURL} -d blah.example.com --manual --preferred-challenges dns certonly
5
6Stage:
7ACMEURL="https://acme-staging-v02.api.letsencrypt.org/directory"
8
9Show Certs:
10certbot certificates
11
12Renew Certs:
13export CERTNAME=mycertname.com
14certbot renew
15certbot renew --cert-name ${CERTNAME} --dry-run
16certbot renew --force-renewal --cert-name ${CERTNAME} --dry-run
17certbot renew --manual --preferred-challenges dns --manual-auth-hook /etc/letsencrypt/CertBotGoDaddyAuthHook.sh
18
19Create PK12 File:
20DOMAIN="example.dev"
21CERT="/etc/letsencrypt/live/${DOMAIN}/fullchain.pem"
22KEY="/etc/letsencrypt/live/${DOMAIN}/privkey.pem"
23
24openssl pkcs12 -export -in ${CERT} -inkey ${KEY} -out ${DOMAIN}.p12
Table of Contents | t |
---|---|
Exposé | ESC |
Full screen slides | e |
Presenter View | p |
Source Files | s |
Slide Numbers | n |
Toggle screen blanking | b |
Show/hide slide context | c |
Notes | 2 |
Help | h |