Skip to content

Commit fbc83aa

Browse files
authored
mtls certification verification updates and added CRL info (#335)
* mtls certification verification updates and added CRL info * more clarification and better notes around mtls cert verification and replication auth handling
1 parent ca7f5aa commit fbc83aa

File tree

6 files changed

+746
-26
lines changed

6 files changed

+746
-26
lines changed

docs/deployments/configuration.md

Lines changed: 127 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -146,50 +146,97 @@ You can also define specific mTLS options by specifying an object for mtls with
146146

147147
`user` - _Type_: string; _Default_: Common Name
148148

149-
This configures a specific username to authenticate as for mTLS connections. If a `user` is defined, any authorized mTLS connection (that authorizes against the certificate authority) will be authenticated as this user. This can also be set to `null`, which indicates that no authentication is performed based on the mTLS authorization. When combined with `required: true`, this can be used to enforce that users must have authorized mTLS _and_ provide credential-based authentication.
149+
This configures a specific username to authenticate as for HTTP mTLS connections. If a `user` is defined, any authorized mTLS connection (that authorizes against the certificate authority) will be authenticated as this user. This can also be set to `null`, which indicates that no authentication is performed based on the mTLS authorization. When combined with `required: true`, this can be used to enforce that users must have authorized mTLS _and_ provide credential-based authentication.
150+
151+
**Note:** MQTT has its own `mqtt.network.mtls.user` setting (see [MQTT configuration](#mqtt)).
150152

151153
`required` - _Type_: boolean; _Default_: false
152154

153-
This can be enabled to require client certificates (mTLS) for all incoming connections. If enabled, any connection that doesn't provide an authorized certificate will be rejected/closed. By default, this is disabled, and authentication can take place with mTLS _or_ standard credential authentication.
155+
This can be enabled to require client certificates (mTLS) for all incoming HTTP connections. If enabled, any connection that doesn't provide an authorized certificate will be rejected/closed. By default, this is disabled, and authentication can take place with mTLS _or_ standard credential authentication.
154156

155-
`certificateVerification` - _Type_: boolean | object; _Default_: true
157+
**Note:** MQTT has its own `mqtt.network.mtls.required` setting (see [MQTT configuration](#mqtt)). Replication uses node-based authentication via certificates or IP addresses, with credential-based fallback (see [Securing Replication Connections](../developers/replication/#securing-connections)).
156158

157-
When mTLS is enabled, Harper verifies the revocation status of client certificates using OCSP (Online Certificate Status Protocol). This ensures that revoked certificates cannot be used for authentication.
159+
`certificateVerification` - _Type_: boolean | object; _Default_: false (disabled)
158160

159-
Set to `false` to disable certificate verification, or configure with an object:
161+
When mTLS is enabled, Harper can verify the revocation status of client certificates using CRL (Certificate Revocation List) and/or OCSP (Online Certificate Status Protocol). This ensures that revoked certificates cannot be used for authentication.
160162

161-
- `timeout` - _Type_: number; _Default_: 5000 - Maximum milliseconds to wait for OCSP response
162-
- `cacheTtl` - _Type_: number; _Default_: 3600000 - Milliseconds to cache verification results (default: 1 hour)
163-
- `failureMode` - _Type_: string; _Default_: 'fail-open' - Behavior when OCSP verification fails:
163+
**Certificate verification is disabled by default** and must be explicitly enabled for production environments where certificate revocation checking is required.
164+
165+
Set to `true` to enable with defaults, `false` to disable, or configure with an object:
166+
167+
**Global Settings:**
168+
169+
- `failureMode` - _Type_: string; _Default_: 'fail-closed' - Global behavior when verification fails:
164170
- `'fail-open'`: Allow connection on verification failure (logs warning)
165-
- `'fail-closed'`: Reject connection on verification failure
171+
- `'fail-closed'`: Reject connection on verification failure (recommended)
172+
173+
**CRL Configuration:** (enabled by default when certificateVerification is enabled)
174+
175+
- `crl.enabled` - _Type_: boolean; _Default_: true - Enable/disable CRL checking
176+
- `crl.timeout` - _Type_: number; _Default_: 10000 - Maximum milliseconds to wait for CRL download
177+
- `crl.cacheTtl` - _Type_: number; _Default_: 86400000 - Milliseconds to cache CRL (24 hours)
178+
- `crl.gracePeriod` - _Type_: number; _Default_: 86400000 - Grace period after CRL nextUpdate (24 hours)
179+
- `crl.failureMode` - _Type_: string; _Default_: 'fail-closed' - CRL-specific failure mode
180+
181+
**OCSP Configuration:** (enabled by default as fallback when certificateVerification is enabled)
182+
183+
- `ocsp.enabled` - _Type_: boolean; _Default_: true - Enable/disable OCSP checking
184+
- `ocsp.timeout` - _Type_: number; _Default_: 5000 - Maximum milliseconds to wait for OCSP response
185+
- `ocsp.cacheTtl` - _Type_: number; _Default_: 3600000 - Milliseconds to cache successful OCSP responses (1 hour)
186+
- `ocsp.errorCacheTtl` - _Type_: number; _Default_: 300000 - Milliseconds to cache OCSP errors (5 minutes)
187+
- `ocsp.failureMode` - _Type_: string; _Default_: 'fail-closed' - OCSP-specific failure mode
188+
189+
**Verification Strategy:**
190+
Harper uses a CRL-first strategy with OCSP fallback. When a client certificate is presented:
191+
192+
1. Check CRL if available (fast, cached locally)
193+
2. Fall back to OCSP if CRL is not available or fails
194+
3. Apply the configured failure mode if both methods fail
166195

167196
Example configurations:
168197

169198
```yaml
170-
# Basic mTLS with default certificate verification
199+
# Basic mTLS without certificate verification (certificate revocation not checked)
171200
http:
172201
mtls: true
173202
```
174203

175204
```yaml
176-
# mTLS with certificate verification disabled (not recommended for production)
205+
# mTLS with certificate verification enabled (recommended for production)
206+
http:
207+
mtls:
208+
certificateVerification: true # Uses all defaults (CRL + OCSP, fail-closed)
209+
```
210+
211+
```yaml
212+
# Require mTLS for all connections + certificate verification
177213
http:
178214
mtls:
179-
required: true
180-
user: user-name
181-
certificateVerification: false
215+
required: true # Reject connections without valid client certificate
216+
certificateVerification: true
182217
```
183218

184219
```yaml
185220
# mTLS with custom verification settings for high-security environments
186221
http:
187222
mtls:
188-
required: true
189223
certificateVerification:
190-
timeout: 10000 # 10 seconds for OCSP response
191-
cacheTtl: 7200000 # Cache results for 2 hours
192-
failureMode: fail-closed # Reject if OCSP check fails
224+
failureMode: fail-closed # Global setting
225+
crl:
226+
timeout: 15000 # 15 seconds for CRL download
227+
cacheTtl: 43200000 # Cache CRLs for 12 hours
228+
gracePeriod: 86400000 # 24 hour grace period
229+
ocsp:
230+
timeout: 8000 # 8 seconds for OCSP response
231+
cacheTtl: 7200000 # Cache results for 2 hours
232+
```
233+
234+
```yaml
235+
# mTLS with CRL only (no OCSP fallback)
236+
http:
237+
mtls:
238+
certificateVerification:
239+
ocsp: false # Disable OCSP, CRL remains enabled
193240
```
194241

195242
---
@@ -302,6 +349,68 @@ The port to use for secure replication connections.
302349

303350
When true, Harper will verify certificates against the Node.js bundled CA store. The bundled CA store is a snapshot of the Mozilla CA store that is fixed at release time.
304351

352+
`mtls` - _Type_: object;
353+
354+
Configures mTLS settings for replication connections. **mTLS is always required for replication** and cannot be disabled (for security reasons). You can configure certificate verification settings:
355+
356+
```yaml
357+
replication:
358+
mtls:
359+
certificateVerification: true # Enable certificate revocation checking
360+
```
361+
362+
`certificateVerification` - _Type_: boolean | object; _Default_: false (disabled)
363+
364+
When enabled, Harper will verify the revocation status of replication peer certificates using CRL and/or OCSP. This follows the same configuration structure as [HTTP certificate verification](#http) documented above.
365+
366+
**Important:** mTLS itself is always enabled for replication connections and cannot be disabled. This setting only controls whether certificate revocation checking (CRL/OCSP) is performed.
367+
368+
Example configurations:
369+
370+
```yaml
371+
# Replication with mTLS but no certificate verification (default)
372+
replication:
373+
hostname: server-one
374+
routes:
375+
- server-two
376+
# mTLS is always enabled, certificate verification is optional
377+
```
378+
379+
```yaml
380+
# Replication with certificate verification enabled (recommended for production)
381+
replication:
382+
hostname: server-one
383+
routes:
384+
- server-two
385+
mtls:
386+
certificateVerification: true # Uses CRL and OCSP with defaults
387+
```
388+
389+
```yaml
390+
# Replication with custom certificate verification settings
391+
replication:
392+
hostname: server-one
393+
routes:
394+
- server-two
395+
mtls:
396+
certificateVerification:
397+
crl:
398+
timeout: 15000
399+
cacheTtl: 43200000
400+
ocsp:
401+
timeout: 8000
402+
```
403+
404+
Certificate verification can also be configured via environment variables:
405+
406+
```bash
407+
REPLICATION_MTLS_CERTIFICATEVERIFICATION=true
408+
REPLICATION_MTLS_CERTIFICATEVERIFICATION_FAILUREMODE=fail-closed
409+
REPLICATION_MTLS_CERTIFICATEVERIFICATION_CRL=true
410+
REPLICATION_MTLS_CERTIFICATEVERIFICATION_CRL_TIMEOUT=15000
411+
REPLICATION_MTLS_CERTIFICATEVERIFICATION_OCSP=true
412+
```
413+
305414
`blobTimeout` - _Type_: number; _Default_: 120000
306415

307416
Amount of time to wait for a blob to be transferred before timing out, measured in milliseconds.

docs/developers/replication/index.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,12 @@ replication:
7575

7676
### Securing Connections
7777

78-
Harper supports the highest levels of security through public key infrastructure based security and authorization. Depending on your security configuration, you can configure Harper in several different ways to build a connected cluster.
78+
Harper supports the highest levels of security through public key infrastructure based security and authorization. Replication connections use WebSocket protocol and support multiple authentication methods depending on your security configuration:
7979

80-
When using certificate-based authentication, Harper automatically performs OCSP (Online Certificate Status Protocol) verification to check if certificates have been revoked. This ensures that compromised certificates cannot be used for replication connections. Certificate verification settings follow the same configuration as HTTP mTLS connections (see [certificate verification configuration](../../deployments/configuration#http)).
80+
- **Certificate-based authentication** (recommended for production): Nodes are identified by the certificate's common name (CN) or Subject Alternative Names (SANs)
81+
- **IP-based authentication** (for development/testing): Nodes are identified by their IP address when using insecure connections (see [Insecure Connection IP-based Authentication](#insecure-connection-ip-based-authentication) below)
82+
83+
When using certificate-based authentication, Harper can automatically perform CRL (Certificate Revocation List) and OCSP (Online Certificate Status Protocol) verification to check if certificates have been revoked. This ensures that compromised certificates cannot be used for replication connections. OCSP and CRL verification works automatically with certificates from public certificate authorities (like Let's Encrypt or DigiCert) when `enableRootCAs` is enabled, as these certificates include the necessary OCSP responder URLs and CRL distribution points. For self-signed certificates or private CAs that don't support OCSP/CRL, you can use Harper's manual certificate revocation feature (see [Revoking Certificates](#revoking-certificates) below). Certificate verification settings follow the same configuration as HTTP mTLS connections (see [certificate verification configuration](../../deployments/configuration#http)).
8184

8285
#### Provide your own certificates
8386

docs/developers/security/certificate-management.md

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,85 @@ tls:
5555
...
5656
```
5757

58+
### Certificate Revocation Checking
59+
60+
When using mTLS, you may also want to enable certificate revocation checking to ensure that revoked certificates cannot be used for authentication, even if they're still within their validity period. Harper supports two industry-standard methods for checking certificate revocation status:
61+
62+
**CRL (Certificate Revocation List)**
63+
64+
- A digitally signed list of revoked certificates published by the Certificate Authority
65+
- Downloaded and cached locally for fast verification
66+
- Updated periodically (typically daily)
67+
- Best for: High-volume verification, offline scenarios, predictable bandwidth usage
68+
69+
**OCSP (Online Certificate Status Protocol)**
70+
71+
- Real-time query to check individual certificate status
72+
- Provides immediate revocation status
73+
- Requires network connection for each check (with caching)
74+
- Best for: Real-time revocation status, certificates without CRL distribution points
75+
76+
**Harper's Approach: CRL-First with OCSP Fallback**
77+
78+
Harper uses a CRL-first strategy for optimal performance:
79+
80+
1. Checks CRL if available (fast, cached locally for 24 hours by default)
81+
2. Falls back to OCSP if CRL is not available or fails (cached for 1 hour by default)
82+
3. Applies the configured failure mode if both methods fail
83+
84+
This strategy provides the best balance of performance, reliability, and security.
85+
86+
**Enabling Certificate Verification**
87+
88+
Certificate revocation checking is disabled by default and must be explicitly enabled:
89+
90+
```yaml
91+
http:
92+
mtls:
93+
required: true
94+
certificateVerification: true # Enable with defaults
95+
```
96+
97+
For production environments with high-security requirements, you can customize the verification settings:
98+
99+
```yaml
100+
http:
101+
mtls:
102+
required: true
103+
certificateVerification:
104+
failureMode: fail-closed # Reject connections on verification failure
105+
crl:
106+
timeout: 15000 # 15 seconds to download CRL
107+
cacheTtl: 43200000 # Cache for 12 hours
108+
ocsp:
109+
timeout: 8000 # 8 seconds for OCSP response
110+
cacheTtl: 7200000 # Cache for 2 hours
111+
```
112+
113+
**Performance Considerations**
114+
115+
- **CRL caching**: CRLs are cached locally, so subsequent verifications are very fast (no network requests)
116+
- **OCSP caching**: Successful OCSP responses are cached (1 hour by default), errors cached for 5 minutes
117+
- **Background refresh**: CRLs are refreshed in the background before expiration to avoid blocking requests
118+
- **Graceful degradation**: Network failures don't block connections in fail-open mode
119+
120+
**When to Use Certificate Verification**
121+
122+
Enable certificate revocation checking when:
123+
124+
- You need to immediately revoke access for compromised certificates
125+
- Compliance or security policies require revocation checking
126+
- You're in a zero-trust security environment
127+
- Client certificates have long validity periods
128+
129+
You may skip it if:
130+
131+
- All certificates have very short validity periods (e.g., < 24 hours)
132+
- You have alternative revocation mechanisms in place
133+
- Performance is critical and risk is acceptable
134+
135+
For detailed configuration options, see the [configuration reference](../../deployments/configuration#http).
136+
58137
### Option: Nginx Reverse Proxy
59138

60139
Instead of enabling HTTPS for Harper, Nginx can be used as a reverse proxy for Harper.

0 commit comments

Comments
 (0)