Skip to content

Commit 51c54fd

Browse files
authored
Add support for TestKit's new SSL tests (#778)
* Enable feature flags `Feature:API:SSLConfig` and `Feature:API:SSLSchemes` * Map TestKit's ssl config options to driver's native options * Adjust TestKit image Docker file to copy customCA certificates
1 parent 23180c3 commit 51c54fd

File tree

4 files changed

+37
-20
lines changed

4 files changed

+37
-20
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,5 @@ docs/build
1717
coverage
1818
.vscode
1919
*.code-workspace
20-
/testkit/CAs
20+
/testkit/CAs
21+
/testkit/CustomCAs

packages/testkit-backend/src/request-handlers.js

+29-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const SUPPORTED_TLS = (() => {
1717
return [];
1818
})();
1919

20-
export function NewDriver (context, data, { writeResponse }) {
20+
export function NewDriver (context, data, wire) {
2121
const {
2222
uri,
2323
authorizationToken: { data: authToken },
@@ -51,17 +51,39 @@ export function NewDriver (context, data, { writeResponse }) {
5151
? address =>
5252
new Promise((resolve, reject) => {
5353
const id = context.addResolverRequest(resolve, reject)
54-
writeResponse('ResolverResolutionRequired', { id, address })
54+
wire.writeResponse('ResolverResolutionRequired', { id, address })
5555
})
5656
: undefined
57-
const driver = neo4j.driver(uri, parsedAuthToken, {
57+
const config = {
5858
userAgent,
5959
resolver,
6060
useBigInt: true,
6161
logging: neo4j.logging.console(process.env.LOG_LEVEL)
62-
})
62+
}
63+
if ('encrypted' in data) {
64+
config.encrypted = data.encrypted ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF'
65+
}
66+
if ('trustedCertificates' in data) {
67+
if (data.trustedCertificates === null) {
68+
config.trust = 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES'
69+
} else if (data.trustedCertificates.length === 0) {
70+
config.trust = 'TRUST_ALL_CERTIFICATES'
71+
} else {
72+
config.trust = 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES'
73+
config.trustedCertificates = data.trustedCertificates.map(
74+
e => '/usr/local/share/custom-ca-certificates/' + e
75+
)
76+
}
77+
}
78+
let driver
79+
try {
80+
driver = neo4j.driver(uri, parsedAuthToken, config)
81+
} catch (err) {
82+
wire.writeError(err)
83+
return
84+
}
6385
const id = context.addDriver(driver)
64-
writeResponse('Driver', { id })
86+
wire.writeResponse('Driver', { id })
6587
}
6688

6789
export function DriverClose (context, data, wire) {
@@ -293,6 +315,8 @@ export function GetFeatures (_context, _params, wire) {
293315
'Feature:Auth:Custom',
294316
'Feature:Auth:Kerberos',
295317
'Feature:Auth:Bearer',
318+
'Feature:API:SSLConfig',
319+
'Feature:API:SSLSchemes',
296320
'AuthorizationExpiredTreatment',
297321
'ConfHint:connection.recv_timeout_seconds',
298322
'Feature:Impersonation',

testkit/CAs/trustedRoot.crt

-10
This file was deleted.

testkit/Dockerfile

+6-4
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,28 @@ RUN apt-get update && \
99
curl \
1010
python3 \
1111
nodejs \
12-
npm \
12+
npm \
1313
firefox \
1414
&& rm -rf /var/lib/apt/lists/*
1515

1616
RUN npm install -g npm@7 \
1717
&& /bin/bash -c "hash -d npm"
1818

1919
# Enable tls v1.0
20-
RUN echo "openssl_conf = openssl_configuration\n"|cat - /etc/ssl/openssl.cnf > /tmp/openssl_conf.cnf \
21-
&& mv /tmp/openssl_conf.cnf /etc/ssl/openssl.cnf
20+
RUN echo "openssl_conf = openssl_configuration\n"|cat - /etc/ssl/openssl.cnf > /tmp/openssl_conf.cnf \
21+
&& mv /tmp/openssl_conf.cnf /etc/ssl/openssl.cnf
2222
RUN echo "[openssl_configuration]\n\
2323
ssl_conf = ssl_configuration\n\
2424
[ssl_configuration]\n\
2525
system_default = tls_system_default\n\
2626
[tls_system_default]\n\
27-
CipherString = DEFAULT:@SECLEVEL=1" >> /etc/ssl/openssl.cnf
27+
CipherString = DEFAULT:@SECLEVEL=1" >> /etc/ssl/openssl.cnf
2828

2929
# Install our own CAs on the image.
3030
# Assumes Linux Debian based image.
3131
COPY CAs/* /usr/local/share/ca-certificates/
32+
# Store custom CAs somewhere where the backend can find them later.
33+
COPY CustomCAs/* /usr/local/share/custom-ca-certificates/
3234
RUN update-ca-certificates
3335

3436
# Creating an user for building the driver and running the tests

0 commit comments

Comments
 (0)