Skip to content

Commit ea92ab3

Browse files
committed
Fix markdown linting errors
Signed-off-by: Christian Kaczmarek <[email protected]>
1 parent 19ebd93 commit ea92ab3

File tree

2 files changed

+84
-36
lines changed

2 files changed

+84
-36
lines changed

docs/guides/ssl/automatic-renewal.md

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,74 +12,87 @@ This guide uses:
1212

1313
## Prerequisites
1414

15-
- **Pi-hole installed and running** on your system.
16-
- **A Cloudflare account** that manages your domains DNS records.
17-
- **Control of a registered domain** (e.g., `mydomain.com`).
15+
- **Pi-hole installed and running** on your system.
16+
- **A Cloudflare account** that manages your domain's DNS records.
17+
- **Control of a registered domain** (e.g., `mydomain.com`).
1818

1919
These prerequisites ensure that you can successfully request and install an SSL certificate using **Cloudflare DNS validation** with `acme.sh`.
20-
This guide uses **Cloudflare DNS** and **Let’s Encrypt**. These instructions can be adapted for any DNS provider and Certificate Authority (CA) that `acme.sh` supports. Simply update the `--dns` and `--server` flags accordingly when issuing your certificate.
20+
21+
This guide uses **Cloudflare DNS** and **Let's Encrypt**. These instructions can be adapted for any DNS provider and Certificate Authority (CA) that `acme.sh` supports. Simply update the `--dns` and `--server` flags accordingly when issuing your certificate.
2122

2223
**Note:** This guide assumes that `acme.sh` runs under the `root` user. The `--reloadcmd` contains commands that require `sudo`, such as removing old certificates, writing the new certificate, and restarting Pi-hole FTL. If you prefer to run `acme.sh` as a regular user, additional configuration is required to allow these commands to execute without a password. Methods for achieving this, such as configuring `sudo` rules, are beyond the scope of this article.
2324

2425
## **1. Install acme.sh as `root`**
2526

2627
Run a login shell as root:
27-
```
28+
29+
```bash
2830
sudo -i
2931
```
3032

3133
Install it:
34+
3235
```bash
3336
curl https://get.acme.sh | sh -s [email protected]
3437
```
3538

3639
Reload .bashrc to register the acme.sh alias:
37-
```
40+
41+
```bash
3842
source .bashrc
3943
```
4044

4145
Verify installation:
46+
4247
```bash
4348
acme.sh --version
4449
```
4550

4651
---
4752

4853
## **2. Set Up Cloudflare DNS API**
54+
4955
For **DNS-based domain verification**, export your **Cloudflare API token**:
5056

5157
```bash
5258
export CF_Token="ofz...xxC"
5359
export CF_Email="[email protected]"
5460
```
61+
5562
This allows `acme.sh` to create the required DNS records automatically.
5663

5764
---
5865

5966
## **3. Issue the SSL Certificate for Pi-hole**
67+
6068
Run:
69+
6170
```bash
6271
acme.sh --issue --dns dns_cf -d ns1.mydomain.com --server letsencrypt
6372
```
73+
6474
This generates:
75+
6576
- **Private key**: `ns1.mydomain.com.key`
6677
- **Full-chain certificate**: `fullchain.cer` (includes `ns1.mydomain.com.cer` + `ca.cer`, in that order)
6778

68-
6979
You do not need these other certificate files:
80+
7081
- **Server certificate**: `ns1.mydomain.com.cer` (included in `fullchain.cer`)
7182
- **Intermediate CA cert**: `ca.cer` (included in `fullchain.cer`)
7283

7384
---
7485

7586
## **4. Install and Apply the SSL Certificate to Pi-hole**
87+
7688
Pi-hole **requires a PEM file** containing **both the private key and server certificate**.
7789

7890
Install the certificate:
91+
7992
```bash
8093
acme.sh --install-cert -d ns1.mydomain.com \
8194
--reloadcmd "sudo rm -f /etc/pihole/tls* && \
82-
sudo cat fullchain.cer ns1.mydomain.com.key | sudo tee /etc/pihole/tls.pem && /
95+
sudo cat fullchain.cer ns1.mydomain.com.key | sudo tee /etc/pihole/tls.pem && \\
8396
sudo service pihole-FTL restart"
8497
```
8598

@@ -92,27 +105,33 @@ This:
92105
---
93106

94107
## **5. Configure Pi-hole**
108+
95109
To avoid domain mismatch warnings (`CERTIFICATE_DOMAIN_MISMATCH`), set the **correct hostname**:
96110

97111
```bash
98112
sudo pihole-FTL --config webserver.domain 'ns1.mydomain.com'
99113
sudo service pihole-FTL restart
100114
```
101115

102-
Fixes:
103-
```
116+
Fixes:
117+
118+
```text
104119
CERTIFICATE_DOMAIN_MISMATCH SSL/TLS certificate /etc/pihole/tls.pem does not match domain pi.hole!
105120
```
106121

107122
---
108123

109124
## **Notes**
125+
110126
- Your **certificate renews automatically** via `acme.sh`'s cron job.
111127
- You can manually renew with:
128+
112129
```bash
113130
acme.sh --renew -d ns1.mydomain.com --force
114131
```
132+
115133
- To check your certificate:
134+
116135
```bash
117136
sudo openssl x509 -in /etc/pihole/tls.pem -text -noout
118137
```

docs/guides/ssl/self-signed.md

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,42 @@ By default, Pi-hole v6 provides a self-signed SSL certificate, but you can creat
77
## Prerequisites
88

99
Install `openssl`:
10-
```
10+
11+
```bash
1112
sudo apt update && sudo apt install openssl -y # For Debian/Ubuntu
1213
sudo yum install openssl -y # For RHEL/CentOS
1314
sudo dnf install openssl -y # For Fedora
1415
```
1516

1617
This guide assumes:
1718

18-
- `openssl` is installed on the same machine that Pi-hole is installed on, but this is not a requirement -
19+
- `openssl` is installed on the same machine that Pi-hole is installed on, but this is not a requirement -
1920
`openssl` can be installed on a machine that is not running Pi-hole; `tls.pem` just needs to be copied to `/etc/pihole` on the target mahcine running Pi-hole.
2021
- All shell commands are executed from the home directory (e.g., `/home/your_user` or `~/`).
2122

2223
---
24+
2325
## Method 1: Use an Internal Certificate Authority CA (Recommended)
26+
2427
- Pros: All future certificates are trusted once you install the CA cert.
2528
- Cons: Requires setting up a CA.
2629

2730
**Summary:** Set up a CA, sign certificates for each server, and install only one CA certificate instead of trusting multiple self-signed certificates.
2831

2932
### Step 1: Create a directory to hold your cert, config, and key files:
30-
```
33+
34+
```bash
3135
mkdir -p ~/crt && cd ~/crt
3236
```
3337

3438
### Step 2: Create a Certificate Authority (CA) Key and Certificate
3539

3640
The CA will be used to sign server certificates.
3741

38-
```
42+
```bash
3943
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -days 3650 -keyout homelabCA.key -out homelabCA.crt -subj "/C=US/O=My Homelab CA/CN=MyHomelabCA"
4044
```
45+
4146
- `x509`: Generates a self-signed certificate (for a CA).
4247
- `newkey ec`: Creates a new EC key.
4348
- `pkeyopt ec_paramgen_curve:prime256v1`: Uses P-256 curve.
@@ -54,11 +59,12 @@ The **CA key** (homelabCA.key) and **CA certificate** (homelabCA.crt) is now rea
5459

5560
### Step 3: Create a Certificate Configuration File (`cert.cnf`)
5661

57-
```
62+
```bash
5863
touch cert.cnf && nano cert.cnf
5964
```
6065

6166
Use the attached [cert.cnf](https://gist.github.com/kaczmar2/e1b5eb635c1a1e792faf36508c5698ee#file-cert-cnf) file as a template:
67+
6268
```ini
6369
# Country Name (C)
6470
#Organization Name (O)
@@ -93,9 +99,11 @@ IP.2 = 10.10.10.116 # Another local IP if needed
9399
### Step 4: Generate a Key and CSR
94100

95101
Use **Elliptic Curve Digital Signature Algorithm (ECDSA)** to generate both the **private key** (`tls.key`) and **Certificate Signing Request (CSR)** (`tls.csr`).
96-
```
102+
103+
```bash
97104
openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -keyout tls.key -out tls.csr -config cert.cnf
98105
```
106+
99107
- `-newkey ec`: Creates a new EC key.
100108
- `-pkeyopt ec_paramgen_curve:prime256v1`: Uses P-256 curve.
101109
- `-nodes` - No password on the private key.
@@ -106,9 +114,11 @@ openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -keyout
106114
### Step 5: Sign the CSR with the CA
107115

108116
This generates your server certificate from the CSR.
109-
```
117+
118+
```bash
110119
openssl x509 -req -in tls.csr -CA homelabCA.crt -CAkey homelabCA.key -CAcreateserial -out tls.crt -days 365 -sha256 -extfile cert.cnf -extensions v3_ext
111120
```
121+
112122
- `-req -in tls.csr`: Uses the Certificate Signing Request (CSR) for signing.
113123
- `-CA homelabCA.crt -CAkey homelabCA.key`: Uses our CA to sign the certificate.
114124
- `-CAcreateserial`:Generates a unique serial number.
@@ -117,64 +127,75 @@ openssl x509 -req -in tls.csr -CA homelabCA.crt -CAkey homelabCA.key -CAcreatese
117127
- `-extfile cert.cnf` -extensions v3_ext → Includes Subject Alternative Names (SAN)s.
118128

119129
### Step 6: Create a Combined `tls.pem` File
120-
```
130+
131+
```bash
121132
cat tls.key tls.crt | tee tls.pem
122133
```
123134

124135
### Step 7: [On Pi-hole Server] Remove existing Pi-hole self-signed cert files:
125-
```
136+
137+
```bash
126138
sudo rm /etc/pihole/tls*
127139
```
128140

129141
### Step 8: [On Pi-hole Server] Copy `tls.pem` (cert+private key) to Pi-hole directory
130-
```
142+
143+
```bash
131144
sudo cp tls.pem /etc/pihole
132145
```
133146

134147
### Step 9. [On Pi-hole Server] Restart Pi-hole
135-
```
148+
149+
```bash
136150
sudo service pihole-FTL restart
137151
```
138152

139153
### Step 10: Install `homelabCA.crt` (CA) in Chrome (this is on your client machine running a browser, for example your Windows PC running Chrome)
140-
Import `homelabCA.crt` into your browser’s **Trusted Root Certificate Store**
154+
155+
Import `homelabCA.crt` into your browser's **Trusted Root Certificate Store**
156+
141157
- Copy `homelabCA.crt` to your local PC
142158
- Open `chrome://certificate-manager` in Chrome
143159
- Click **Manage Imported Certificates**
144160
- Click **Trusted Root Certification Authorities**
145-
- Click **Import, Next, Finish**
161+
- Click **Import, Next, Finish**
146162

147163
### Issuing additional server certificates with your CA (Optional)
148-
You can issue additional certificates for your other servers using the CA you created in **step 2**, and you do not have to re-install the CA certificate in your browser.
164+
165+
You can issue additional certificates for your other servers using the CA you created in **step 2**, and you do not have to re-install the CA certificate in your browser.
149166
Just run the commands listed in **steps 4 and 5** again:
150167

151-
```
168+
```bash
152169
openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -keyout tls2.key -out tls2.csr -config cert2.cnf
153170
```
154-
```
171+
172+
```bash
155173
openssl x509 -req -in tls.csr -CA homelabCA.crt -CAkey homelabCA.key -CAcreateserial -out tls2.crt -days 365 -sha256 -extfile cert2.cnf -extensions v3_ext
156174
```
157175

158176
---
159177

160178
## Method 2: Use a Self-Signed Certificate and Manually Trust It
179+
161180
- Pros: Simple, no need to set up a CA.
162181
- Cons: Must manually add each self-signed cert to your browser.
163182

164183
**Summary:** Generate a self-signed certificate and install it in your browser. You must manually trust each certificate, so this is adequate for a single server setup.
165184

166185
### Step 1: Create a directory to hold your cert, config, and key files:
167-
```
186+
187+
```bash
168188
mkdir -p ~/crt && cd ~/crt
169189
```
170190

171191
### Step 2: Create a Certificate Configuration File (`cert.cnf`)
172192

173-
```
193+
```bash
174194
touch cert.cnf && nano cert.cnf
175195
```
176196

177197
Use the attached [cert.cnf](https://gist.github.com/kaczmar2/e1b5eb635c1a1e792faf36508c5698ee#file-cert-cnf) file as a template:
198+
178199
```ini
179200
# Country Name (C)
180201
#Organization Name (O)
@@ -207,10 +228,11 @@ IP.2 = 10.10.10.116 # Another local IP if needed
207228
```
208229

209230
### Step 3: Generate a key and Self-Signed Certificate
210-
Use **Elliptic Curve Digital Signature Algorithm (ECDSA)** to generate both the **private key** (`tls.key`) and the **Self-Signed Certificate** (`tls.crt`).
211-
```
212-
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -days 365 -keyout tls.key -out tls.crt -config cert.cnf
213231

232+
Use **Elliptic Curve Digital Signature Algorithm (ECDSA)** to generate both the **private key** (`tls.key`) and the **Self-Signed Certificate** (`tls.crt`).
233+
234+
```bash
235+
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -days 365 -keyout tls.key -out tls.crt -config cert.cnf
214236
```
215237

216238
- `x509`: Creates a self-signed certificate.
@@ -223,32 +245,39 @@ openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:prime256v1 -nodes -days
223245
- `-config cert.cnf` Uses cert configuration file `cert.cnf` defined above.
224246

225247
### Step 4: Create a Combined `tls.pem` File
226-
```
248+
249+
```bash
227250
cat tls.key tls.crt | tee tls.pem
228251
```
229252

230253
### Step 5: [On Pi-hole Server] Remove existing Pi-hole self-signed cert files:
231-
```
254+
255+
```bash
232256
sudo rm /etc/pihole/tls*
233257
```
234258

235259
### Step 6: [On Pi-hole Server] Copy `tls.pem` (cert+private key) to Pi-hole directory
236-
```
260+
261+
```bash
237262
sudo cp tls.pem /etc/pihole
238263
```
239264

240265
### Step 7. [On Pi-hole Server] Restart Pi-hole
241-
```
266+
267+
```bash
242268
sudo service pihole-FTL restart
243269
```
244270

245271
### Step 8: Install `tls.crt` (cert) in Chrome (this is on your client machine running a browser, for example your Windows PC running Chrome)
246-
Import `tls.crt` into your browser’s **Trusted Root Certificate Store**
272+
273+
Import `tls.crt` into your browser's **Trusted Root Certificate Store**
274+
247275
- Copy `tls.crt` to your local PC
248276
- Open `chrome://certificate-manager` in Chrome
249277
- Click **Manage Imported Certificates**
250278
- Click **Trusted Root Certification Authorities**
251279
- Click **Import, Next, Finish**
252280

253281
## Installation of Self-Signed Certs for Mobile Devices
282+
254283
- See: Pi-hole API > [TLS/SSL](../../api/tls.md)

0 commit comments

Comments
 (0)