Skip to content

Instantly share code, notes, and snippets.

@ali-ince
Last active November 12, 2018 11:30
Show Gist options
  • Save ali-ince/de09eb143c873167f68cc26202c1bc3d to your computer and use it in GitHub Desktop.
Save ali-ince/de09eb143c873167f68cc26202c1bc3d to your computer and use it in GitHub Desktop.
var (
driver neo4j.Driver
err error
)
useConsoleLogger := func() func(config *neo4j.Config) {
return func(config *neo4j.Config) {
config.Log = neo4j.ConsoleLogger(neo4j.ERROR)
}
}
trustSystemStore := func() func(config *neo4j.Config) {
return func(config *neo4j.Config) {
// This turns on host name verification and checks certificate trust against trust store
// pointed by SSL_CERT_FILE and SSL_CERT_DIR environment variables. See more at
// https://www.openssl.org/docs/man1.1.0/ssl/SSL_CTX_set_default_verify_paths.html
config.TrustStrategy = neo4j.TrustSystem(true)
}
}
// trustCerts := func(certs ...*x509.Certificate) func(config *neo4j.Config) {
// return func(config *neo4j.Config) {
// // This turns on host name verification and checks the trust against the provided list
// // of certificates.
// config.TrustStrategy = neo4j.TrustOnly(true, certs...)
// }
// }
if driver, err = neo4j.NewDriver(uri, neo4j.BasicAuth(username, password, ""), useConsoleLogger(), trustSystemStore()); err != nil {
return err
}
defer driver.Close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment