Kalle Elmér
Kalle Elmér

Reputation: 151

Connect to Neo4j database over HTTPS with JDBC

I'm using a Neo4j database in standalone server mode from my Java application and connecting to it using JDBC like this:

Class.forName("org.neo4j.jdbc.Driver");
DriverManager.getConnection("jdbc:neo4j://server.example.com/", "neo4j", "mypassword");

This results in a plain HTTP connection. How can I make it use HTTPS?

Upvotes: 1

Views: 722

Answers (1)

Stefan Armbruster
Stefan Armbruster

Reputation: 39915

HTTPS is possible with the jdbc driver. You need to use a jdbc url like this:

jdbc:neo4j:https://localhost:7473/

If you use self signed certificates you need to configure your truststore to accept the server's certificate:

keytool -import -v -trustcacerts -file ~/neo4j-enterprise-2.3.2/conf/ssl/snakeoil.cert -keystore cacerts.jks -keypass changeit -storepass changeit

And the JVM using the JDBC driver needs to be aware of the created truststore:

java -Djavax.net.ssl.trustStore=cacerts.jks <your_classpath_and_main_class>

Upvotes: 1

Related Questions