Skip to content

Commit 938c6bb

Browse files
committed
feat(security): add SSL/TLS custom cert support and optional SSL verification skip
- Enhance SSL/TLS configuration with support for custom CA or self-signed certificates via N8N_CERT_PATH. - Introduce N8N_SKIP_SSL_VERIFICATION environment variable to optionally disable SSL cert verification (for development only). - Add detailed SSL/TLS troubleshooting guide documentation with common errors, fixes, and best practices. - Update n8n API client to use custom cert and conditionally disable SSL verification with proper warnings. - Improve logging to warn about insecure SSL skip usage.
1 parent 560e0c5 commit 938c6bb

File tree

9 files changed

+683
-3
lines changed

9 files changed

+683
-3
lines changed

.env.example

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,4 +215,11 @@ ENABLE_MULTI_TENANT=false
215215
# Test Configuration
216216
N8N_TEST_CLEANUP_ENABLED=true # Enable automatic cleanup of test workflows
217217
N8N_TEST_TAG=mcp-integration-test # Tag applied to all test workflows
218-
N8N_TEST_NAME_PREFIX=[MCP-TEST] # Name prefix for test workflows
218+
N8N_TEST_NAME_PREFIX=[MCP-TEST] # Name prefix for test workflows
219+
220+
# Custom SSL certificate for self-signed n8n instances
221+
# Path to the server's .crt file (absolute or relative)
222+
# Supports both CA certificates and self-signed server certificates
223+
# Example: N8N_CERT_PATH=/path/to/n8n-server.crt
224+
# Docker: Mount certificate and use container path (e.g., /app/certs/n8n.crt)
225+
# N8N_CERT_PATH=

README.md

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,125 @@ Deploy n8n-MCP to Railway's cloud platform with zero configuration:
474474

475475
**Restart Claude Desktop after updating configuration** - That's it! 🎉
476476

477+
## 🔐 SSL/TLS Configuration
478+
479+
### Using Custom CA Certificates (Recommended)
480+
481+
If your n8n instance uses a custom or self-signed SSL certificate, configure the `N8N_CERT_PATH` environment variable to point to your certificate file (PEM format):
482+
483+
- For self-signed certificates: provide the server's certificate itself
484+
- For custom CA: provide the CA certificate that signed the server's certificate
485+
486+
This approach maintains full SSL verification while trusting your specific certificate.
487+
488+
### Using with npx
489+
490+
Add the certificate path to your Claude Desktop configuration:
491+
492+
```json
493+
{
494+
"mcpServers": {
495+
"n8n-mcp": {
496+
"command": "npx",
497+
"args": ["n8n-mcp"],
498+
"env": {
499+
"MCP_MODE": "stdio",
500+
"LOG_LEVEL": "error",
501+
"DISABLE_CONSOLE_OUTPUT": "true",
502+
"N8N_API_URL": "https://your-n8n-instance.com",
503+
"N8N_API_KEY": "your-api-key",
504+
"N8N_CERT_PATH": "/path/to/your/certificate.crt"
505+
}
506+
}
507+
}
508+
}
509+
```
510+
511+
### Using with Docker
512+
513+
Mount your certificate file as a volume and set the environment variable:
514+
515+
```bash
516+
docker run -i --rm --init \
517+
-v /path/to/your/certificate.crt:/app/certs/n8n.crt:ro \
518+
-e MCP_MODE=stdio \
519+
-e LOG_LEVEL=error \
520+
-e DISABLE_CONSOLE_OUTPUT=true \
521+
-e N8N_API_URL=https://your-n8n-instance.com \
522+
-e N8N_API_KEY=your-api-key \
523+
-e N8N_CERT_PATH=/app/certs/n8n.crt \
524+
ghcr.io/czlonkowski/n8n-mcp:latest
525+
```
526+
527+
For Claude Desktop configuration with Docker:
528+
529+
```json
530+
{
531+
"mcpServers": {
532+
"n8n-mcp": {
533+
"command": "docker",
534+
"args": [
535+
"run", "-i", "--rm", "--init",
536+
"-v", "/path/to/your/certificate.crt:/app/certs/n8n.crt:ro",
537+
"-e", "MCP_MODE=stdio",
538+
"-e", "LOG_LEVEL=error",
539+
"-e", "DISABLE_CONSOLE_OUTPUT=true",
540+
"-e", "N8N_API_URL=https://your-n8n-instance.com",
541+
"-e", "N8N_API_KEY=your-api-key",
542+
"-e", "N8N_CERT_PATH=/app/certs/n8n.crt",
543+
"ghcr.io/czlonkowski/n8n-mcp:latest"
544+
]
545+
}
546+
}
547+
}
548+
```
549+
550+
### Using with docker-compose
551+
552+
See the commented certificate configuration in `docker-compose.yml` and `docker-compose.n8n.yml`. Uncomment the relevant sections and adjust the certificate path.
553+
554+
### Troubleshooting Certificate Issues
555+
556+
Common issues and quick fixes:
557+
- **UNABLE_TO_VERIFY_LEAF_SIGNATURE** → Missing root certificate in your bundle
558+
- **SELF_SIGNED_CERT_IN_CHAIN** → Configure certificate as trusted CA or skip verification
559+
- **ERR_TLS_CERT_ALTNAME_INVALID** → Domain name doesn't match certificate
560+
561+
📚 **For detailed solutions, see our [SSL Troubleshooting Guide](./docs/SSL_TROUBLESHOOTING.md)** which covers:
562+
- Complete error messages and solutions
563+
- How to create proper certificate bundles
564+
- Diagnostic commands and debugging tips
565+
- Solutions for Let's Encrypt, self-signed, and corporate certificates
566+
567+
### Disabling SSL Verification (Development Only)
568+
569+
⚠️ **WARNING**: This option completely disables SSL certificate verification and should ONLY be used for local development or testing environments.
570+
571+
If you're unable to provide a valid certificate and need to connect to a development server, you can disable SSL verification:
572+
573+
```json
574+
{
575+
"mcpServers": {
576+
"n8n-mcp": {
577+
"command": "npx",
578+
"args": ["n8n-mcp"],
579+
"env": {
580+
"MCP_MODE": "stdio",
581+
"N8N_API_URL": "https://your-n8n-instance.com",
582+
"N8N_API_KEY": "your-api-key",
583+
"N8N_SKIP_SSL_VERIFICATION": "true"
584+
}
585+
}
586+
}
587+
}
588+
```
589+
590+
**Important Security Notes**:
591+
- Never use `N8N_SKIP_SSL_VERIFICATION` in production environments
592+
- This disables protection against man-in-the-middle attacks
593+
- Always prefer providing the correct certificate via `N8N_CERT_PATH`
594+
- The server will log warnings when SSL verification is disabled
595+
477596
## 🔧 n8n Integration
478597

479598
Want to use n8n-MCP with your n8n instance? Check out our comprehensive [n8n Deployment Guide](./docs/N8N_DEPLOYMENT.md) for:

docker-compose.n8n.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,18 @@ services:
4848
- MCP_AUTH_TOKEN=${MCP_AUTH_TOKEN}
4949
- AUTH_TOKEN=${MCP_AUTH_TOKEN}
5050
- LOG_LEVEL=${LOG_LEVEL:-info}
51+
52+
# Optional: Self-signed certificate support
53+
# Uncomment if your n8n instance uses a self-signed SSL certificate
54+
# Note: Also uncomment the corresponding volume mount below
55+
# - N8N_CERT_PATH=/app/certs/n8n.crt
5156
volumes:
5257
- ./data:/app/data:ro
5358
- mcp_logs:/app/logs
59+
60+
# Optional: Mount certificate file for self-signed n8n instances
61+
# Uncomment and adjust the path to your certificate file
62+
# - /path/to/your/certificate.crt:/app/certs/n8n.crt:ro
5463
networks:
5564
- n8n-network
5665
depends_on:

docker-compose.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,19 @@ services:
3434
# N8N_API_KEY: ${N8N_API_KEY}
3535
# N8N_API_TIMEOUT: ${N8N_API_TIMEOUT:-30000}
3636
# N8N_API_MAX_RETRIES: ${N8N_API_MAX_RETRIES:-3}
37+
38+
# Optional: Self-signed certificate support
39+
# Uncomment if your n8n instance uses a self-signed SSL certificate
40+
# N8N_CERT_PATH: /app/certs/n8n.crt
3741

3842
# Volumes for persistence
3943
volumes:
4044
- n8n-mcp-data:/app/data
45+
46+
# Optional: Mount certificate file for self-signed n8n instances
47+
# Uncomment and adjust the path to your certificate file
48+
# Example: ./certs/n8n.crt:/app/certs/n8n.crt:ro
49+
# - /path/to/your/certificate.crt:/app/certs/n8n.crt:ro
4150

4251
# Port mapping
4352
ports:

docs/DOCKER_README.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ docker run -d \
6868
| `AUTH_RATE_LIMIT_WINDOW` | Rate limit window in ms (v2.16.3+) | `900000` (15 min) | No |
6969
| `AUTH_RATE_LIMIT_MAX` | Max auth attempts per window (v2.16.3+) | `20` | No |
7070
| `WEBHOOK_SECURITY_MODE` | SSRF protection: `strict`/`moderate`/`permissive` (v2.16.3+) | `strict` | No |
71+
| `N8N_CERT_PATH` | Path to SSL certificate for self-signed n8n instances | - | No |
7172

7273
*Either `AUTH_TOKEN` or `AUTH_TOKEN_FILE` must be set for HTTP mode. If both are set, `AUTH_TOKEN` takes precedence.
7374

@@ -286,6 +287,7 @@ docker ps --format "table {{.Names}}\t{{.Status}}"
286287
docker inspect n8n-mcp | jq '.[0].State.Health'
287288
```
288289

290+
<<<<<<< HEAD
289291
## 🔒 Security Features (v2.16.3+)
290292

291293
### Rate Limiting
@@ -378,6 +380,76 @@ your-domain.com {
378380
- No unnecessary packages installed
379381
- Regular security updates via GitHub Actions
380382

383+
## 🔐 SSL Certificate Configuration
384+
385+
### Self-Signed Certificates
386+
387+
If your n8n instance uses a self-signed SSL certificate, you need to mount the certificate file and configure the `N8N_CERT_PATH` environment variable:
388+
389+
#### Basic Docker Run
390+
391+
```bash
392+
# Run with mounted certificate
393+
docker run -d \
394+
--name n8n-mcp \
395+
-e MCP_MODE=http \
396+
-e AUTH_TOKEN=your-secure-token \
397+
-e N8N_API_URL=https://your-n8n-instance.com \
398+
-e N8N_API_KEY=your-api-key \
399+
-e N8N_CERT_PATH=/app/certs/n8n.crt \
400+
-v /path/to/your/certificate.crt:/app/certs/n8n.crt:ro \
401+
-p 3000:3000 \
402+
ghcr.io/czlonkowski/n8n-mcp:latest
403+
```
404+
405+
#### Docker Compose Configuration
406+
407+
Add certificate configuration to your `docker-compose.yml`:
408+
409+
```yaml
410+
services:
411+
n8n-mcp:
412+
image: ghcr.io/czlonkowski/n8n-mcp:latest
413+
environment:
414+
MCP_MODE: http
415+
AUTH_TOKEN: ${AUTH_TOKEN}
416+
N8N_API_URL: https://your-n8n-instance.com
417+
N8N_API_KEY: ${N8N_API_KEY}
418+
N8N_CERT_PATH: /app/certs/n8n.crt
419+
volumes:
420+
- n8n-mcp-data:/app/data
421+
- /path/to/your/certificate.crt:/app/certs/n8n.crt:ro
422+
ports:
423+
- "3000:3000"
424+
```
425+
426+
#### Certificate Troubleshooting
427+
428+
**Common Issues:**
429+
430+
1. **Certificate not found error:**
431+
```bash
432+
# Verify the certificate is properly mounted
433+
docker exec n8n-mcp ls -la /app/certs/
434+
```
435+
436+
2. **Permission denied:**
437+
```bash
438+
# Ensure certificate is readable
439+
chmod 644 /path/to/your/certificate.crt
440+
```
441+
442+
3. **Invalid certificate format:**
443+
- Certificate must be in PEM format (.crt or .pem)
444+
- Check with: `openssl x509 -in certificate.crt -text -noout`
445+
446+
4. **Still can't connect:**
447+
```bash
448+
# Test certificate directly
449+
openssl s_client -connect your-n8n-instance.com:443 \
450+
-CAfile /path/to/your/certificate.crt -showcerts
451+
```
452+
381453
## 📊 Resource Management
382454

383455
### Memory Limits

docs/HTTP_DEPLOYMENT.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,69 @@ Skip HTTP entirely and use stdio mode directly:
137137

138138
💡 **Save your AUTH_TOKEN** - clients will need it to connect!
139139

140+
### Self-Signed Certificates
141+
142+
If your n8n instance uses a self-signed SSL certificate, you need to configure the `N8N_CERT_PATH` environment variable:
143+
144+
#### Docker with Certificate
145+
146+
```bash
147+
# 1. Create environment file with certificate path
148+
cat > .env << EOF
149+
AUTH_TOKEN=$(openssl rand -base64 32)
150+
USE_FIXED_HTTP=true
151+
MCP_MODE=http
152+
PORT=3000
153+
N8N_CERT_PATH=/app/certs/n8n.crt
154+
N8N_API_URL=https://your-n8n-instance.com
155+
N8N_API_KEY=your-api-key-here
156+
EOF
157+
158+
# 2. Deploy with Docker and mount certificate
159+
docker run -d \
160+
--name n8n-mcp \
161+
--restart unless-stopped \
162+
--env-file .env \
163+
-v /path/to/your/certificate.crt:/app/certs/n8n.crt:ro \
164+
-p 3000:3000 \
165+
ghcr.io/czlonkowski/n8n-mcp:latest
166+
```
167+
168+
#### Docker Compose with Certificate
169+
170+
Add the following to your `docker-compose.yml`:
171+
172+
```yaml
173+
services:
174+
n8n-mcp:
175+
image: ghcr.io/czlonkowski/n8n-mcp:latest
176+
environment:
177+
# ... other environment variables ...
178+
N8N_CERT_PATH: /app/certs/n8n.crt
179+
volumes:
180+
- n8n-mcp-data:/app/data
181+
- /path/to/your/certificate.crt:/app/certs/n8n.crt:ro
182+
```
183+
184+
#### Local Development with Certificate
185+
186+
```bash
187+
# Set the certificate path
188+
export N8N_CERT_PATH=/path/to/your/certificate.crt
189+
export N8N_API_URL=https://your-n8n-instance.com
190+
export N8N_API_KEY=your-api-key
191+
192+
# Start the server
193+
npm run start:http
194+
```
195+
196+
#### Certificate Troubleshooting
197+
198+
- **Format**: Certificate must be in PEM format (.crt or .pem file)
199+
- **Permissions**: Ensure the certificate file is readable by the process
200+
- **Path**: Use absolute paths to avoid resolution issues
201+
- **Testing**: You can test the certificate with `openssl s_client -connect your-n8n-instance.com:443 -showcerts`
202+
140203
## ⚙️ Configuration
141204

142205
### Required Environment Variables

0 commit comments

Comments
 (0)