@@ -145,6 +145,29 @@ const TrustStrategy = {
145145 socket . on ( 'error' , onFailure ) ;
146146 return socket ;
147147 } ,
148+ TRUST_SYSTEM_CA_SIGNED_CERTIFICATES : function ( opts , onSuccess , onFailure ) {
149+
150+ let tlsOpts = {
151+ // Because we manually check for this in the connect callback, to give
152+ // a more helpful error to the user
153+ rejectUnauthorized : false
154+ } ;
155+ let socket = tls . connect ( opts . port , opts . host , tlsOpts , function ( ) {
156+ if ( ! socket . authorized ) {
157+ onFailure ( newError ( "Server certificate is not trusted. If you trust the database you are connecting to, use " +
158+ "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES and add" +
159+ " the signing certificate, or the server certificate, to the list of certificates trusted by this driver" +
160+ " using `neo4j.v1.driver(.., { trustedCertificates:['path/to/certificate.crt']}). This " +
161+ " is a security measure to protect against man-in-the-middle attacks. If you are just trying " +
162+ " Neo4j out and are not concerned about encryption, simply disable it using `encrypted=false` in the driver" +
163+ " options." ) ) ;
164+ } else {
165+ onSuccess ( ) ;
166+ }
167+ } ) ;
168+ socket . on ( 'error' , onFailure ) ;
169+ return socket ;
170+ } ,
148171 TRUST_ON_FIRST_USE : function ( opts , onSuccess , onFailure ) {
149172 let tlsOpts = {
150173 // Because we manually verify the certificate against known_hosts
0 commit comments