配置Bolt服务器和HTTPS服务器的SSL策略

本节介绍如何配置Bolt和HTTPS服务器的SSL策略。

Neo4j 3.5 允许使用默认配置进行加密连接。如果在服务器启动前没有安装证书,则会自动生成自签名证书。然而,从 4.0 版本开始,默认加密设置是关闭的,并且在未提供证书时,Neo4j 不再生成证书。因此,Bolt 服务器只允许明文连接,并且 HTTPS 服务器默认未启用。

表 1. 3.5 和 4.x 服务器之间的加密和证书差异
3.5 Neo4j Bolt 服务器 4.0 Neo4j Bolt 服务器 3.5 Neo4j HTTPS 服务器 4.0 Neo4j HTTPS 服务器

服务器已启用

客户端连接加密

可选

不允许

始终

始终

证书

如果未提供,则自动生成自签名证书。

如果未提供,则自动生成自签名证书。

默认证书路径

$neo4jHome/certificates

$neo4jHome/certificates

默认证书名称

neo4j.key

neo4j.cert

private.key

public.crt

neo4j.key

neo4j.cert

private.key

public.crt

要在 4.x 中重新启用加密,您必须在 neo4j.conf 文件中配置 SSL 策略。假定 Bolt 服务器的证书名为 public.crtprivate.key 并位于 `$neo4jHome/certificates/bolt` 文件夹中,HTTPS 服务器的证书也使用相同的文件名并位于 `$neo4jHome/certificates/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.
© . All rights reserved.