为 Bolt 服务器和 HTTPS 服务器配置 SSL 策略
本节描述如何为 Bolt 和 HTTPS 服务器配置 SSL 策略。
Neo4j 3.5 在默认配置下允许加密连接。如果在服务器启动前未安装证书,系统会自动生成自签名证书。然而,从 4.0 开始,默认的加密设置已关闭,且 Neo4j 在未提供证书时不再生成证书。因此,Bolt 服务器仅允许明文连接,HTTPS 服务器默认也未启用。
| 3.5 Neo4j Bolt 服务器 | 4.0 Neo4j Bolt 服务器 | 3.5 Neo4j HTTPS 服务器 | 4.0 Neo4j HTTPS 服务器 | |
|---|---|---|---|---|
服务器已启用 |
是 |
是 |
是 |
否 |
客户端连接的加密 |
可选 |
不允许 |
始终 |
始终 |
证书 |
如果未提供,则自动生成自签名证书。 |
None |
如果未提供,则自动生成自签名证书。 |
None |
默认证书路径 |
|
None |
|
None |
默认证书名称 |
|
|
|
|
要在 4.x 中重新启用加密,需要在 neo4j.conf 文件中配置 SSL 策略。假设在 $neo4jHome/certificates/bolt 文件夹下为 Bolt 服务器准备了名为 public.crt 和 private.key 的证书,同时在 $neo4jHome/certificates/https 文件夹下为 HTTPS 服务器准备了相同文件名的证书。下面的示例演示了如何为 Bolt 服务器重新打开加密并重新启用 HTTPS 服务器。
示例 1. 为 Bolt 4.0 服务器开启加密。
dbms.connector.bolt.enabled=true
dbms.connector.bolt.tls_level=OPTIONAL # allows both encrypted and unencrypted driver connections
dbms.ssl.policy.bolt.enabled=true
dbms.ssl.policy.bolt.base_directory=certificates/bolt
#dbms.ssl.policy.bolt.private_key=private.key # Optional if the file name is the same as the default.
#dbms.ssl.policy.bolt.public_certificate=public.crt # Optional if the file name is the same as the default.
示例 2. 启用 HTTPS 4.0 服务器。
dbms.connector.https.enabled=true
dbms.ssl.policy.https.enabled=true
dbms.ssl.policy.https.base_directory=certificates/https
#dbms.ssl.policy.https.private_key=private.key # Optional if the file name is the same as the default.
#dbms.ssl.policy.https.public_certificate=public.crt # Optional if the file name is the same as the default.