Hi everyone,
I’m trying to set up n8n on my Raspberry Pi using Docker with HTTPS enabled via a self-signed certificate. However, I keep encountering the following error in the logs:
Error: error:1C800064:Provider routines::bad decrypt
Here’s what I’ve done so far:
- Initially, I tried installing n8n using NPM, but I couldn’t get HTTPS working with my self-signed certificate. After running into several issues, I decided to uninstall the NPM version and switch to Docker.
- I’m fairly sure I removed all traces of the old NPM installation, including the
~/.n8ndirectory and any globally installed packages. - Generated a self-signed certificate (
selfsigned.crt) and private key (selfsigned.key) using OpenSSL. - Placed the certificate and key in
/home/lanie/n8n/pkion my Raspberry Pi. - Mapped this directory to
/opt/custom-certificatesin the Docker container using thevolumessection of mydocker-compose.yml. - Set the environment variables
N8N_PROTOCOL,N8N_SSL_CERT, andN8N_SSL_KEYto enable HTTPS and point to the certificate and key files. - Verified permissions and ownership for the certificate and key:
chmod 644 /home/lanie/n8n/pki/selfsigned.crt chmod 600 /home/lanie/n8n/pki/selfsigned.key chown 1000:1000 /home/lanie/n8n/pki/selfsigned.crt chown 1000:1000 /home/lanie/n8n/pki/selfsigned.key
Despite this, I still get the “bad decrypt” error when starting n8n.
Logs:
Here are the relevant logs from docker-compose logs n8n:
2024-12-30T05:30:24.762824099Z Error: error:1C800064:Provider routines::bad decrypt
at setKey (node:internal/tls/secure-context:93:11)
at configSecureContext (node:internal/tls/secure-context:209:7)
at Object.createSecureContext (node:_tls_common:114:3)
at Server.setSecureContext (node:_tls_wrap:1488:27)
at Server (node:_tls_wrap:1352:8)
at new Server (node:https:80:3)
at Object.createServer (node:https:135:10)
at Server.init (/usr/local/lib/node_modules/n8n/dist/abstract-server.js:135:33)
at Start.init (/usr/local/lib/node_modules/n8n/dist/commands/base-command.js:86:9)
at Start.init (/usr/local/lib/node_modules/n8n/dist/commands/start.js:160:9)
Exiting due to an error.
Docker Compose File:
Here’s my docker-compose.yml file:
version: '3'
services:
n8n:
container_name: n8n
image: docker.n8n.io/n8nio/n8n
ports:
- 5678:5678
volumes:
- /home/lanie/n8n/pki:/opt/custom-certificates
environment:
- N8N_PROTOCOL=https
- N8N_SSL_CERT=/opt/custom-certificates/selfsigned.crt
- N8N_SSL_KEY=/opt/custom-certificates/selfsigned.key
- N8N_ENCRYPTION_KEY=9ZXBIEqLCXuFJmrFX9d9dEPX91sd9JdnqyhfuxsDXCk=
- N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS=true
System Info:
-N8N Version: 1.7.2.1
- Database: SQLite
- Executions process: default
- Running Method: Docker-compose
- System version: Debian GNU/Linux 12 (bookworm)
Additional Notes:
- The certificate and key are in PEM format (.crt and .key), and I verified that they match using
openssl x509 -noout -modulusandopenssl rsa -noout -modulus. - I’ve also tried regenerating the certificate and key, but the issue persists.
- The container starts fine if I disable HTTPS by changing
N8N_PROTOCOLtohttp, but then I can’t access it from my Windows computer.
Does anyone know what might be causing this issue? Could there be residual effects from my previous NPM installation? Any help would be greatly appreciated!