Skip to content

Add support for TestKit's new SSL tests #778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ docs/build
coverage
.vscode
*.code-workspace
/testkit/CAs
/testkit/CAs
/testkit/CustomCAs
34 changes: 29 additions & 5 deletions packages/testkit-backend/src/request-handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SUPPORTED_TLS = (() => {
return [];
})();

export function NewDriver (context, data, { writeResponse }) {
export function NewDriver (context, data, wire) {
const {
uri,
authorizationToken: { data: authToken },
Expand Down Expand Up @@ -51,17 +51,39 @@ export function NewDriver (context, data, { writeResponse }) {
? address =>
new Promise((resolve, reject) => {
const id = context.addResolverRequest(resolve, reject)
writeResponse('ResolverResolutionRequired', { id, address })
wire.writeResponse('ResolverResolutionRequired', { id, address })
})
: undefined
const driver = neo4j.driver(uri, parsedAuthToken, {
const config = {
userAgent,
resolver,
useBigInt: true,
logging: neo4j.logging.console(process.env.LOG_LEVEL)
})
}
if ('encrypted' in data) {
config.encrypted = data.encrypted ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF'
}
if ('trustedCertificates' in data) {
if (data.trustedCertificates === null) {
config.trust = 'TRUST_SYSTEM_CA_SIGNED_CERTIFICATES'
} else if (data.trustedCertificates.length === 0) {
config.trust = 'TRUST_ALL_CERTIFICATES'
} else {
config.trust = 'TRUST_CUSTOM_CA_SIGNED_CERTIFICATES'
config.trustedCertificates = data.trustedCertificates.map(
e => '/usr/local/share/custom-ca-certificates/' + e
)
}
}
let driver
try {
driver = neo4j.driver(uri, parsedAuthToken, config)
} catch (err) {
wire.writeError(err)
return
}
const id = context.addDriver(driver)
writeResponse('Driver', { id })
wire.writeResponse('Driver', { id })
}

export function DriverClose (context, data, wire) {
Expand Down Expand Up @@ -293,6 +315,8 @@ export function GetFeatures (_context, _params, wire) {
'Feature:Auth:Custom',
'Feature:Auth:Kerberos',
'Feature:Auth:Bearer',
'Feature:API:SSLConfig',
'Feature:API:SSLSchemes',
'AuthorizationExpiredTreatment',
'ConfHint:connection.recv_timeout_seconds',
'Feature:Impersonation',
Expand Down
10 changes: 0 additions & 10 deletions testkit/CAs/trustedRoot.crt

This file was deleted.

10 changes: 6 additions & 4 deletions testkit/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,28 @@ RUN apt-get update && \
curl \
python3 \
nodejs \
npm \
npm \
firefox \
&& rm -rf /var/lib/apt/lists/*

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

# Enable tls v1.0
RUN echo "openssl_conf = openssl_configuration\n"|cat - /etc/ssl/openssl.cnf > /tmp/openssl_conf.cnf \
&& mv /tmp/openssl_conf.cnf /etc/ssl/openssl.cnf
RUN echo "openssl_conf = openssl_configuration\n"|cat - /etc/ssl/openssl.cnf > /tmp/openssl_conf.cnf \
&& mv /tmp/openssl_conf.cnf /etc/ssl/openssl.cnf
RUN echo "[openssl_configuration]\n\
ssl_conf = ssl_configuration\n\
[ssl_configuration]\n\
system_default = tls_system_default\n\
[tls_system_default]\n\
CipherString = DEFAULT:@SECLEVEL=1" >> /etc/ssl/openssl.cnf
CipherString = DEFAULT:@SECLEVEL=1" >> /etc/ssl/openssl.cnf

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

# Creating an user for building the driver and running the tests
Expand Down