我是Neo4J DB的全新用户 . 我需要从我的Java项目连接到DB . 我正在使用 neo4j-java-driver 1.6.3 . 我正在使用 neo4j-enterprise edition 3.4.9 (通过Ubuntu 16.04中的Debian存储库安装) .
我已设法 Build 无身份验证连接和基本身份验证连接 . 我在连接启用 SSL 的服务器时遇到问题 . 我试图通过以下代码连接:
Driver driver = GraphDatabase.driver(url,AuthTokens.basic(username,password),Config.build() . withTrustStrategy(Config.TrustStrategy.trustCustomCertificateSignedBy(certFile)) . toConfig());
我收到以下错误:
sun.security.validator.ValidatorException:找不到可信证书
如何在此创建必要的证书文件?我也是SSL证书的新手 .
我的neo4j.conf文件如下所示:
dbms.directories.data = / var / lib / neo4j / data dbms.directories.plugins = / var / lib / neo4j / plugins dbms.directories.certificates = / var / lib / neo4j / certificates dbms.directories.logs = / var / log / neo4j dbms.directories.lib = / usr / share / neo4j / lib dbms.directories.run = / var / run / neo4j dbms.directories.metrics = / var / lib / neo4j / metrics dbms.directories.import = / var / lib / neo4j / import dbms.memory.heap.initial_size = 512m dbms.memory.heap.max_size = 512m dbms.connectors.default_listen_address = 0.0.0.0 dbms.connectors.default_advertised_address = XXXX dbms.connector.bolt.enabled = true dbms.connector.bolt.tls_level =可选dbms.connector.http.enabled = true dbms.connector.https.enabled = true bolt.ssl_policy = bigd dbms.ssl.policy.bigd.base_directory = / var / lib / neo4j / certificates / bigd dbms.ssl.policy.bigd.private_key = / var / lib / neo4j / certificates / bigd / private.key dbms.ssl.policy.bigd.public_certificate = / var / lib / neo4j / certificates / bigd / public .crt dbms.ssl.policy.bigd.client_auth = require
private.key和public.crt我创建如下:
sudo openssl req -newkey rsa:2048 -nodes -out neo4j.csr -keyout private.key sudo openssl x509 -req -days 3650 -in neo4j.csr -CA ca.cert -CAkey ca.key -set_serial 01 -out public .CRT
我在java代码中创建了certFile,如下所示:
sudo openssl genrsa -out neo4j-client.key 2048 sudo openssl req -new -out neo4j-client.csr -key neo4j-client.key -subj“/CN=10.0.1.67/O=example.com”sudo openssl x509 -req -in neo4j-client.csr -CA ca.cert -CAkey ca.key -CAserial ./ca.srl -out neo4j-client.crt -days 3650
我想我可能会遗漏一些配置,或者我没有正确创建证书 . 我怎样才能知道我错过了什么?