Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
6 changes: 4 additions & 2 deletions .evergreen/csfle/kms_failpoint_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,10 @@ def __init__(self, server_address, Handler, use_tls=True):

if use_tls:
server_dir = os.path.dirname(__file__)
cert_file = os.path.join(server_dir, "..", "x509gen", "server.pem")
ca_file = os.path.join(server_dir, "..", "x509gen", "ca.pem")
default_cert = os.path.join(server_dir, "..", "x509gen", "server.pem")
default_ca = os.path.join(server_dir, "..", "x509gen", "ca.pem")
cert_file = os.environ.get("CSFLE_TLS_CERT_FILE", default_cert)
ca_file = os.environ.get("CSFLE_TLS_CA_FILE", default_ca)

context = ssl.SSLContext(ssl.PROTOCOL_TLS)
context.load_verify_locations(ca_file)
Expand Down
4 changes: 4 additions & 0 deletions .evergreen/csfle/setup-secrets.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@ PARENT_DIR=$(dirname $SCRIPT_DIR)
export CSFLE_TLS_CA_FILE=${CSFLE_TLS_CA_FILE:-"$PARENT_DIR/x509gen/ca.pem"}
export CSFLE_TLS_CERT_FILE=${CSFLE_TLS_CERT_FILE:-"$PARENT_DIR/x509gen/server.pem"}
export CSFLE_TLS_CLIENT_CERT_FILE=${CSFLE_TLS_CLIENT_CERT_FILE:-"$PARENT_DIR/x509gen/client.pem"}
export CSFLE_TLS_EXPIRED_FILE=${CSFLE_TLS_EXPIRED_FILE:-"$PARENT_DIR/x509gen/expired.pem"}
export CSFLE_TLS_WRONG_HOST_FILE=${CSFLE_TLS_WRONG_HOST_FILE:-"$PARENT_DIR/x509gen/wrong-host.pem"}

if [[ "${OSTYPE:?}" == cygwin ]]; then
CSFLE_TLS_CA_FILE=$(cygpath -m $CSFLE_TLS_CA_FILE)
CSFLE_TLS_CERT_FILE=$(cygpath -m $CSFLE_TLS_CERT_FILE)
CSFLE_TLS_CLIENT_CERT_FILE=$(cygpath -m $CSFLE_TLS_CLIENT_CERT_FILE)
CSFLE_TLS_EXPIRED_FILE=$(cygpath -m $CSFLE_TLS_EXPIRED_FILE)
CSFLE_TLS_WRONG_HOST_FILE=$(cygpath -m $CSFLE_TLS_WRONG_HOST_FILE)
fi

pushd $SCRIPT_DIR
Expand Down
2 changes: 2 additions & 0 deletions .evergreen/csfle/setup_secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ def b64url(data: bytes) -> str:
"CSFLE_TLS_CA_FILE",
"CSFLE_TLS_CERT_FILE",
"CSFLE_TLS_CLIENT_CERT_FILE",
"CSFLE_TLS_EXPIRED_FILE",
"CSFLE_TLS_WRONG_HOST_FILE",
]:
fid.write(f'\nexport {key}="{os.environ[key]}"'.encode())
fid.write(b"\n")
Expand Down
4 changes: 2 additions & 2 deletions .evergreen/csfle/start-servers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ echo "Starting KMIP Server...done."


echo "Starting HTTP Server 1..."
$COMMAND kms_http_server.py --ca_file $CSFLE_TLS_CA_FILE --cert_file ../x509gen/expired.pem --port 9000 > http1.log 2>&1 &
$COMMAND kms_http_server.py --ca_file $CSFLE_TLS_CA_FILE --cert_file $CSFLE_TLS_EXPIRED_FILE --port 9000 > http1.log 2>&1 &
echo "$!" >> kmip_pids.pid
sleep 1
cat http1.log
echo "Starting HTTP Server 1...done."


echo "Starting HTTP Server 2..."
$COMMAND kms_http_server.py --ca_file $CSFLE_TLS_CA_FILE --cert_file ../x509gen/wrong-host.pem --port 9001 > http2.log 2>&1 &
$COMMAND kms_http_server.py --ca_file $CSFLE_TLS_CA_FILE --cert_file $CSFLE_TLS_WRONG_HOST_FILE --port 9001 > http2.log 2>&1 &
echo "$!" >> kmip_pids.pid
sleep 1
cat http2.log
Expand Down
13 changes: 13 additions & 0 deletions .evergreen/orchestration/drivers_orchestration.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,12 @@ def get_options():
"--tls-ca-file",
help="A .pem file that contains the root certificate chain for the server",
)
other_group.add_argument(
"--tls-allow-invalid-certificates",
action="store_true",
help="Whether to pass --tlsAllowInvalidCertificates to mongod, bypassing "
"certificate revocation (OCSP) enforcement",
Comment thread
blink1073 marked this conversation as resolved.
Outdated
)
other_group.add_argument(
"--arch",
help="the architecture. if unspecified, the arch will be inferred.",
Expand Down Expand Up @@ -366,6 +372,13 @@ def get_orchestration_data(opts):
)
data["requireApiVersion"] = "1"

if opts.tls_allow_invalid_certificates:
if "sslParams" not in data:
raise ValueError(
"--tls-allow-invalid-certificates requires TLS to be configured, but no sslParams found in orchestration data"
)
data["sslParams"]["tlsAllowInvalidCertificates"] = True

# If running on Docker, update the orchestration file to be docker-friendly.
if os.environ.get("DOCKER_RUNNING"):
handle_docker_config(data)
Expand Down
3 changes: 1 addition & 2 deletions .evergreen/orchestration/mongodb_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,9 @@ def _get_cluster_options(input: dict, opts: Any, static=False) -> Dict[str, Any]
for key, value in input["sslParams"].items():
if key == "sslPEMKeyFile":
key = "tlsCertificateKeyFile" # noqa: PLW2901
if key == "sslCAFile":
elif key == "sslCAFile":
key = "tlsCAFile" # noqa: PLW2901
_append_arg(args, key, value)

if input.get("login"):
users.append(
{
Expand Down
Loading