Skip to content

Commit 9d930b7

Browse files
committed
Make TRUST_SYSTEM_CA_SIGNED_CERTIFICATES the default when encrypted
1 parent 2589eb6 commit 9d930b7

File tree

6 files changed

+156
-164
lines changed

6 files changed

+156
-164
lines changed

gulpfile.babel.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,13 @@ gulp.task('set', function () {
168168
.pipe(gulp.dest('./'))
169169
})
170170

171-
const neo4jHome = path.resolve('./build/neo4j')
172-
173171
gulp.task('start-neo4j', function (done) {
174-
sharedNeo4j.start(neo4jHome, process.env.NEOCTRL_ARGS)
172+
sharedNeo4j.start()
175173
done()
176174
})
177175

178176
gulp.task('stop-neo4j', function (done) {
179-
sharedNeo4j.stop(neo4jHome)
177+
sharedNeo4j.stop()
180178
done()
181179
})
182180

src/internal/browser/browser-channel.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -264,16 +264,16 @@ function determineWebSocketScheme (config, protocolSupplier) {
264264

265265
if (encryptionOn) {
266266
// encryption explicitly requested in the config
267-
if (!trust || trust === 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES') {
267+
if (!trust || trust === 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES') {
268268
// trust strategy not specified or the only supported strategy is specified
269269
return { scheme: 'wss', error: null }
270270
} else {
271271
const error = newError(
272272
'The browser version of this driver only supports one trust ' +
273-
"strategy, 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES'. " +
273+
"strategy, 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES'. " +
274274
trust +
275275
' is not supported. Please ' +
276-
'either use TRUST_CUSTOM_CA_SIGNED_CERTIFICATES or disable encryption by setting ' +
276+
'either use TRUST_SYSTEM_CA_SIGNED_CERTIFICATES or disable encryption by setting ' +
277277
'`encrypted:"' +
278278
ENCRYPTION_OFF +
279279
'"` in the driver configuration.'

src/internal/node/node-channel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ function trustStrategyName (config) {
190190
if (config.trust) {
191191
return config.trust
192192
}
193-
return 'TRUST_ALL_CERTIFICATES'
193+
return 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES'
194194
}
195195

196196
/**

test/examples.test.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,6 @@ describe('#integration examples', () => {
144144
})
145145

146146
it('config trust example', async () => {
147-
if (version.compareTo(VERSION_4_0_0) >= 0) {
148-
pending('address within security work')
149-
}
150-
151147
// tag::config-trust[]
152148
const driver = neo4j.driver(uri, neo4j.auth.basic(user, password), {
153149
encrypted: 'ENCRYPTION_ON',

test/internal/node/tls.test.js

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ describe('#integration trust', () => {
3737
}
3838
})
3939

40-
beforeEach(() => {
41-
if (serverVersion.compareTo(VERSION_4_0_0) >= 0) {
42-
pending('address within security work')
43-
}
44-
})
45-
4640
describe('trust-all-certificates', () => {
4741
let driver
4842

@@ -102,7 +96,7 @@ describe('#integration trust', () => {
10296
driver = neo4j.driver('bolt://localhost', sharedNeo4j.authToken, {
10397
encrypted: true,
10498
trust: 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES',
105-
trustedCertificates: [neo4jCertPath()]
99+
trustedCertificates: [sharedNeo4j.neo4jCertPath()]
106100
})
107101

108102
// When
@@ -138,9 +132,21 @@ describe('#integration trust', () => {
138132
done()
139133
})
140134
})
141-
})
142135

143-
function neo4jCertPath () {
144-
return sharedNeo4j.neo4jCertPath(path.join('build', 'neo4j'))
145-
}
136+
it('should reject unknown certificates if trust not specified', done => {
137+
// Given
138+
driver = neo4j.driver('bolt://localhost', sharedNeo4j.authToken, {
139+
encrypted: true
140+
})
141+
142+
// When
143+
driver
144+
.session()
145+
.run('RETURN 1')
146+
.catch(err => {
147+
expect(err.message).toContain('Server certificate is not trusted')
148+
done()
149+
})
150+
})
151+
})
146152
})

0 commit comments

Comments
 (0)