配置 n8n 使用你自己的证书颁发机构或自签名证书(Configure n8n to use your own certificate authority or self-signed certificate)#
你可以将自己的证书颁发机构 (CA) 或自签名证书添加到 n8n。这意味着你可以信任某个特定的 SSL 证书,而不是信任所有无效的证书,因为那样可能存在安全风险。
🌐 You can add your own certificate authority (CA) or self-signed certificate to n8n. This means you are able to trust a certain SSL certificate instead of trusting all invalid certificates, which is a potential security risk.
在版本 1.42.0 中添加
此功能在 1.42.0 及更高版本中可用。
要使用此功能,你需要将证书放入一个文件夹,并将该文件夹挂载到容器中的 /opt/custom-certificates。映射到 /opt/custom-certificates 的外部路径必须允许容器写入。
🌐 To use this feature you need to place your certificates in a folder and mount the folder to /opt/custom-certificates in the container. The external path that you map to /opt/custom-certificates must be writable by the container.
Docker#
下面的示例假设你有一个名为 pki 的文件夹,该文件夹中包含你的证书,位置可以是在你执行命令的目录中,或者在你的 Docker Compose 文件旁边。
🌐 The examples below assume you have a folder called pki that contains your certificates in either the directory you run the command from or next to your docker compose file.
Docker CLI#
在使用命令行接口 (CLI) 时,你可以从命令行使用 -v 标志:
🌐 When using the CLI you can use the -v flag from the command line:
1 2 3 4 5 | |
Docker Compose#
1 2 3 4 5 6 7 8 9 | |
你还应该为导入的证书设置正确的权限。你可以在容器运行后执行此操作(假设容器名称为 n8n):
🌐 You should also give the right permissions to the imported certs. You can do this once the container is running (assuming n8n as the container name):
1 | |
自定义信任库的证书要求(Certificate requirements for Custom Trust Store)#
支持的证书类型:
🌐 Supported certificate types:
- 根证书授权(Root CA Certificates):这些是由证书颁发机构发出的证书,用于签署其他证书。信任这些证书可以接受该CA签署的所有证书。
- 自签名证书:服务器自己创建并签署的证书。仅信任这些证书以接受到该特定服务器的连接。
你必须使用 PEM 格式。
🌐 You must use PEM format:
- 带有 BEGIN/END 标记的文本格式
- 支持的文件扩展名:
.pem、.crt、.cer - 包含公钥证书(无需私钥)。
例如:
🌐 For example:
1 2 3 4 | |
系统不接受:
🌐 The system doesn't accept:
- DER/二进制格式文件
- PKCS#7 (.p7b) 文件
- PKCS#12 (.pfx, .p12) 文件
- 私钥文件
- 使用前将这些格式转换为 PEM 格式