配置 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 服务器 | |
---|---|---|---|---|
服务器已启用 |
是 |
是 |
是 |
否 |
客户端连接上的加密 |
可选 |
不允许 |
始终 |
始终 |
证书 |
如果未提供,则自动生成自签名证书。 |
无 |
如果未提供,则自动生成自签名证书。 |
无 |
默认证书路径 |
|
无 |
|
无 |
默认证书名称 |
|
|
|
|
为了在 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.