@@ -106,14 +106,6 @@ function storeFingerprint( serverId, knownHostsPath, fingerprint, cb ) {
106106}
107107
108108const TrustStrategy = {
109- /**
110- * @deprecated Since version 1.0. Will be deleted in a future version. {@link #TRUST_CUSTOM_CA_SIGNED_CERTIFICATES}.
111- */
112- TRUST_SIGNED_CERTIFICATES : function ( config , onSuccess , onFailure ) {
113- console . warn ( '`TRUST_SIGNED_CERTIFICATES` has been deprecated as option and will be removed in a future version of ' +
114- "the driver. Please use `TRUST_CUSTOM_CA_SIGNED_CERTIFICATES` instead." ) ;
115- return TrustStrategy . TRUST_CUSTOM_CA_SIGNED_CERTIFICATES ( config , onSuccess , onFailure ) ;
116- } ,
117109 TRUST_CUSTOM_CA_SIGNED_CERTIFICATES : function ( config , onSuccess , onFailure ) {
118110 if ( ! config . trustedCertificates || config . trustedCertificates . length === 0 ) {
119111 onFailure ( newError ( "You are using TRUST_CUSTOM_CA_SIGNED_CERTIFICATES as the method " +
@@ -159,62 +151,6 @@ const TrustStrategy = {
159151 socket . on ( 'error' , onFailure ) ;
160152 return configureSocket ( socket ) ;
161153 } ,
162- /**
163- * @deprecated in 1.1 in favour of {@link #TRUST_ALL_CERTIFICATES}. Will be deleted in a future version.
164- */
165- TRUST_ON_FIRST_USE : function ( config , onSuccess , onFailure ) {
166- console . warn ( '`TRUST_ON_FIRST_USE` has been deprecated as option and will be removed in a future version of ' +
167- "the driver. Please use `TRUST_ALL_CERTIFICATES` instead." ) ;
168-
169- const tlsOpts = newTlsOptions ( config . url . host ) ;
170- const socket = tls . connect ( config . url . port , config . url . host , tlsOpts , function ( ) {
171- const serverCert = socket . getPeerCertificate ( /*raw=*/ true ) ;
172-
173- if ( ! serverCert . raw ) {
174- // If `raw` is not available, we're on an old version of NodeJS, and
175- // the raw cert cannot be accessed (or, at least I couldn't find a way to)
176- // therefore, we can't generate a SHA512 fingerprint, meaning we can't
177- // do TOFU, and the safe approach is to fail.
178- onFailure ( newError ( "You are using a version of NodeJS that does not " +
179- "support trust-on-first use encryption. You can either upgrade NodeJS to " +
180- "a newer version, use `trust:TRUST_CUSTOM_CA_SIGNED_CERTIFICATES` in your driver " +
181- "config instead, or disable encryption using `encrypted:\"" + ENCRYPTION_OFF + "\"`." ) ) ;
182- return ;
183- }
184-
185- const serverFingerprint = crypto . createHash ( 'sha512' ) . update ( serverCert . raw ) . digest ( 'hex' ) ;
186- const knownHostsPath = config . knownHostsPath || path . join ( userHome ( ) , ".neo4j" , "known_hosts" ) ;
187- const serverId = config . url . hostAndPort ;
188-
189- loadFingerprint ( serverId , knownHostsPath , ( knownFingerprint ) => {
190- if ( knownFingerprint === serverFingerprint ) {
191- onSuccess ( ) ;
192- } else if ( knownFingerprint == null ) {
193- storeFingerprint ( serverId , knownHostsPath , serverFingerprint , ( err ) => {
194- if ( err ) {
195- return onFailure ( err ) ;
196- }
197- return onSuccess ( ) ;
198- } ) ;
199- } else {
200- onFailure ( newError ( "Database encryption certificate has changed, and no longer " +
201- "matches the certificate stored for " + serverId + " in `" + knownHostsPath +
202- "`. As a security precaution, this driver will not automatically trust the new " +
203- "certificate, because doing so would allow an attacker to pretend to be the Neo4j " +
204- "instance we want to connect to. The certificate provided by the server looks like: " +
205- serverCert + ". If you trust that this certificate is valid, simply remove the line " +
206- "starting with " + serverId + " in `" + knownHostsPath + "`, and the driver will " +
207- "update the file with the new certificate. You can configure which file the driver " +
208- "should use to store this information by setting `knownHosts` to another path in " +
209- "your driver configuration - and you can disable encryption there as well using " +
210- "`encrypted:\"" + ENCRYPTION_OFF + "\"`." ) )
211- }
212- } ) ;
213- } ) ;
214- socket . on ( 'error' , onFailure ) ;
215- return configureSocket ( socket ) ;
216- } ,
217-
218154 TRUST_ALL_CERTIFICATES : function ( config , onSuccess , onFailure ) {
219155 const tlsOpts = newTlsOptions ( config . url . host ) ;
220156 const socket = tls . connect ( config . url . port , config . url . host , tlsOpts , function ( ) {
0 commit comments