Skip to content

Commit 29508e0

Browse files
CSHARP-3299: Enable Secure Tests on Linux. (mongodb#499)
CSHARP-3299: Enable Secure Tests on Linux.
1 parent c5afced commit 29508e0

File tree

4 files changed

+52
-22
lines changed

4 files changed

+52
-22
lines changed

evergreen/add-certs-if-needed.sh

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ set -o errexit # Exit the script with an error if any of the commands fail
77
# SSL Set to enable SSL. Values are "ssl" / "nossl" (default)
88
# OCSP_TLS_SHOULD_SUCCEED Set to test OCSP. Values are true/false/nil
99
# OCSP_ALGORITHM Set to test OCSP. Values are rsa/ecdsa/nil
10+
# OS Set to access operating system
1011

1112
SSL=${SSL:-nossl}
1213
OCSP_TLS_SHOULD_SUCCEED=${OCSP_TLS_SHOULD_SUCCEED:-nil}
@@ -16,16 +17,28 @@ if [[ "$SSL" != "ssl" ]]; then
1617
exit 0
1718
fi
1819

19-
if [[ "$OS" =~ Windows|windows ]]; then
20-
certutil.exe -addstore "Root" ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem
21-
22-
if [[ "$OCSP_TLS_SHOULD_SUCCEED" != "nil" && "$OCSP_ALGORITHM" != "nil" ]]; then
23-
certutil.exe -addstore "Root" ${DRIVERS_TOOLS}/.evergreen/ocsp/${OCSP_ALGORITHM}/ca.pem
20+
function make_trusted() {
21+
echo "CA.pem certificate $1"
22+
if [[ "$OS" =~ Windows|windows ]]; then
23+
# makes the client.pem trusted
24+
certutil.exe -addstore "Root" $1
25+
elif [[ "$OS" =~ Ubuntu|ubuntu ]]; then
26+
# makes the client.pem trusted
27+
# note: .crt is the equivalent format as .pem, but we need to make this renaming because update-ca-certificates supports only .crt
28+
sudo cp -f $1 /usr/local/share/ca-certificates/ca.crt
29+
sudo update-ca-certificates
30+
elif [[ "$OS" =~ macos ]]; then
31+
# mac OS, the same trick as for above ubuntu step
32+
sudo cp -f $1 ~/ca.crt
33+
sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/ca.crt
34+
else
35+
echo "Unsupported OS:${OS}" 1>&2 # write to stderr
36+
exit 1
2437
fi
25-
else
26-
keytool -import -trustcacerts -file ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem -keystore Root -storepass changeit -noprompt -alias x509
38+
}
2739

28-
if [[ "$OCSP_TLS_SHOULD_SUCCEED" != "nil" && "$OCSP_ALGORITHM" != "nil" ]]; then
29-
keytool -import -trustcacerts -file ${DRIVERS_TOOLS}/.evergreen/ocsp/${OCSP_ALGORITHM}/ca.pem -keystore Root -storepass changeit -noprompt -alias ${OCSP_ALGORITHM}
30-
fi
40+
make_trusted ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem
41+
42+
if [[ "$OCSP_TLS_SHOULD_SUCCEED" != "nil" && "$OCSP_ALGORITHM" != "nil" ]]; then
43+
make_trusted ${DRIVERS_TOOLS}/.evergreen/ocsp/${OCSP_ALGORITHM}/ca.pem
3144
fi

evergreen/evergreen.yml

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ functions:
259259
. ./evergreen/set-virtualenv.sh
260260
. ./evergreen/set-temp-fle-aws-creds.sh
261261
${PREPARE_SHELL}
262-
SSL=${SSL} evergreen/add-certs-if-needed.sh
262+
SSL=${SSL} OS=${OS} evergreen/add-certs-if-needed.sh
263263
AUTH=${AUTH} \
264264
SSL=${SSL} \
265265
MONGODB_URI="${MONGODB_URI}" \
@@ -1254,7 +1254,17 @@ buildvariants:
12541254
- name: test-netstandard20
12551255
- name: test-netstandard21
12561256

1257-
- matrix_name: "unsecure-tests-posix"
1257+
# ubuntu 18 does not support SSL until 4.0
1258+
- matrix_name: "secure-tests-linux"
1259+
matrix_spec: { version: ["4.0", "4.2", "4.4", "latest"], topology: "*", auth: "auth", ssl: "ssl", os: "ubuntu-1804" }
1260+
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"
1261+
tags: ["tests-variant"]
1262+
tasks:
1263+
- name: test-netstandard15
1264+
- name: test-netstandard20
1265+
- name: test-netstandard21
1266+
1267+
- matrix_name: "unsecure-tests-linux"
12581268
matrix_spec: { version: "*", topology: "*", auth: "noauth", ssl: "nossl", os: "ubuntu-1804" }
12591269
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"
12601270
tags: ["tests-variant"]
@@ -1263,6 +1273,17 @@ buildvariants:
12631273
- name: test-netstandard20
12641274
- name: test-netstandard21
12651275

1276+
# macos-1014 does not support SSL until 3.2
1277+
- matrix_name: "secure-tests-macOS"
1278+
matrix_spec: { version: ["3.2", "3.6", "4.0", "4.2", "4.4", "latest"], topology: "*", auth: "auth", ssl: "ssl", os: "macos-1014" }
1279+
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"
1280+
tags: ["tests-variant"]
1281+
tasks:
1282+
# - name: test-netstandard15: auth tests fail on macos with test-netstandard15 due to the fact that this TF uses openssl that is missed on the current boxes
1283+
# Starting in .NET Core 2.0, .NET Core switched to using the default Apple Security Framework on macOS.
1284+
- name: test-netstandard20
1285+
- name: test-netstandard21
1286+
12661287
- matrix_name: "unsecure-tests-macOS"
12671288
matrix_spec: { version: "*", topology: "*", auth: "noauth", ssl: "nossl", os: "macos-1014" }
12681289
display_name: "${version} ${topology} ${auth} ${ssl} ${os}"

evergreen/run-tests.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,16 +121,16 @@ if [[ "$OS" =~ Windows|windows ]]; then
121121
powershell.exe '.\build.ps1 -target' $TARGET
122122
else
123123
powershell.exe \
124-
'$env:MONGO_X509_CLIENT_CERTIFICATE_PATH="'${MONGO_X509_CLIENT_CERTIFICATE_PATH}'";'\
125-
'$env:MONGO_X509_CLIENT_CERTIFICATE_PASSWORD="'${MONGO_X509_CLIENT_CERTIFICATE_PASSWORD}'";'\
124+
'$env:MONGO_X509_CLIENT_CERTIFICATE_PATH="${MONGO_X509_CLIENT_CERTIFICATE_PATH}";'\
125+
'$env:MONGO_X509_CLIENT_CERTIFICATE_PASSWORD="${MONGO_X509_CLIENT_CERTIFICATE_PASSWORD}";'\
126126
'.\build.ps1 -target' $TARGET
127127
fi
128128
else
129129
if [[ -z "$MONGO_X509_CLIENT_CERTIFICATE_PATH" && -z "$MONGO_X509_CLIENT_CERTIFICATE_PASSWORD" ]]; then
130130
./build.sh -target=$TARGET
131131
else
132-
MONGO_X509_CLIENT_CERTIFICATE_PATH="'${MONGO_X509_CLIENT_CERTIFICATE_PATH}'" \
133-
MONGO_X509_CLIENT_CERTIFICATE_PASSWORD="'${MONGO_X509_CLIENT_CERTIFICATE_PASSWORD}'" \
132+
MONGO_X509_CLIENT_CERTIFICATE_PATH="${MONGO_X509_CLIENT_CERTIFICATE_PATH}" \
133+
MONGO_X509_CLIENT_CERTIFICATE_PASSWORD="${MONGO_X509_CLIENT_CERTIFICATE_PASSWORD}" \
134134
./build.sh -target=$TARGET
135135
fi
136136
fi

tests/MongoDB.Driver.Tests/ClusterTests.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,8 @@ public void SelectServer_loadbalancing_prose_test([Values(false, true)] bool asy
6565
.ClusterType(ClusterType.Sharded);
6666
RequireMultipleShardRouters();
6767

68-
// temporary disable the test on Win Auth topologies, due to operations timings irregularities
69-
if (CoreTestConfiguration.ConnectionString.Tls == true &&
70-
RequirePlatform.GetCurrentOperatingSystem() == SupportedOperatingSystem.Windows)
71-
{
72-
throw new SkipException("Win Auth topologies temporary not supported due to timings irregularities.");
73-
}
68+
// temporary disable the test on Auth envs due to operations timings irregularities
69+
RequireServer.Check().Authentication(false);
7470

7571
const string applicationName = "loadBalancingTest";
7672
const int threadsCount = 10;

0 commit comments

Comments
 (0)