Skip to content

Commit 84331ac

Browse files
authored
Support KMIP as a KMS provider for CSFLE (#813)
Client-side field level encryption can be configured to use any KMIP-compliant key management server (KMS). JAVA-4373
1 parent e3dac02 commit 84331ac

File tree

20 files changed

+5452
-514
lines changed

20 files changed

+5452
-514
lines changed

.evergreen/.evg.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -689,6 +689,20 @@ functions:
689689
cd ${DRIVERS_TOOLS}/.evergreen/csfle
690690
./kmstlsvenv/bin/python3 -u kms_http_server.py -v --ca_file ../x509gen/ca.pem --cert_file ../x509gen/${CERT_FILE} --port 8000
691691
692+
start-kms-kmip-server:
693+
- command: shell.exec
694+
params:
695+
script: |
696+
${PREPARE_SHELL}
697+
cd ${DRIVERS_TOOLS}/.evergreen/csfle
698+
. ./activate_venv.sh
699+
- command: shell.exec
700+
params:
701+
background: true
702+
script: |
703+
cd ${DRIVERS_TOOLS}/.evergreen/csfle
704+
./kmstlsvenv/bin/python3 -u kms_kmip_server.py
705+
692706
"run-kms-tls-test":
693707
- command: shell.exec
694708
type: test
@@ -807,6 +821,7 @@ tasks:
807821

808822
- name: "test"
809823
commands:
824+
- func: "start-kms-kmip-server"
810825
- func: "bootstrap mongo-orchestration"
811826
- func: "run tests"
812827

@@ -836,6 +851,7 @@ tasks:
836851

837852
- name: "accept-api-version-2-test"
838853
commands:
854+
- func: "start-kms-kmip-server"
839855
- func: "bootstrap mongo-orchestration"
840856
vars:
841857
ORCHESTRATION_FILE: "versioned-api-testing.json"

.evergreen/run-tests.sh

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,6 @@ RELATIVE_DIR_PATH="$(dirname "${BASH_SOURCE:-$0}")"
4747
############################################
4848

4949
provision_ssl () {
50-
echo "SSL !"
51-
5250
# We generate the keystore and truststore on every run with the certs in the drivers-tools repo
5351
if [ ! -f client.pkc ]; then
5452
openssl pkcs12 -CAfile ${DRIVERS_TOOLS}/.evergreen/x509gen/ca.pem -export -in ${DRIVERS_TOOLS}/.evergreen/x509gen/client.pem -out client.pkc -password pass:bithere
@@ -59,6 +57,9 @@ provision_ssl () {
5957

6058
# We add extra gradle arguments for SSL
6159
export GRADLE_EXTRA_VARS="-Pssl.enabled=true -Pssl.keyStoreType=pkcs12 -Pssl.keyStore=`pwd`/client.pkc -Pssl.keyStorePassword=bithere -Pssl.trustStoreType=jks -Pssl.trustStore=`pwd`/mongo-truststore -Pssl.trustStorePassword=changeit"
60+
}
61+
62+
provision_multi_mongos_uri_for_ssl () {
6263
# Arguments for auth + SSL
6364
if [ "$AUTH" != "noauth" ] || [ "$TOPOLOGY" == "replica_set" ]; then
6465
export MONGODB_URI="${MONGODB_URI}&ssl=true&sslInvalidHostNameAllowed=true"
@@ -110,8 +111,11 @@ if [ "$COMPRESSOR" != "" ]; then
110111
fi
111112
fi
112113

114+
# Set up keystore/truststore regardless, as they are required for testing KMIP
115+
provision_ssl
116+
113117
if [ "$SSL" != "nossl" ]; then
114-
provision_ssl
118+
provision_multi_mongos_uri_for_ssl
115119
fi
116120

117121
if [ "$SAFE_FOR_MULTI_MONGOS" == "true" ]; then

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ ext {
4747
nettyVersion = '4.1.43.Final'
4848
snappyVersion = '1.1.4'
4949
zstdVersion = '1.3.8-3'
50-
mongoCryptVersion = '1.2.1'
50+
mongoCryptVersion = '1.3.0'
5151
projectReactorVersion = 'Californium-SR23'
5252
junitBomVersion = '5.6.2'
5353
gitVersion = getGitVersion()

driver-core/src/main/com/mongodb/AutoEncryptionSettings.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,13 @@ public String getKeyVaultNamespace() {
232232
* <ul>
233233
* <li>email: a String, the service account email to authenticate.</li>
234234
* <li>privateKey: a String or byte[], the encoded PKCS#8 encrypted key</li>
235-
* <li>endPoint: optional String, a host with optional port. e.g. "example.com" or "example.com:443".</li>
235+
* <li>endpoint: optional String, a host with optional port. e.g. "example.com" or "example.com:443".</li>
236+
* </ul>
237+
* <p>
238+
* For "kmip", the properties are:
239+
* </p>
240+
* <ul>
241+
* <li>endpoint: a String, the endpoint as a host with required port. e.g. "example.com:443".</li>
236242
* </ul>
237243
* <p>
238244
* For "local", the properties are:

driver-core/src/main/com/mongodb/ClientEncryptionSettings.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,13 @@ public String getKeyVaultNamespace() {
166166
* <ul>
167167
* <li>email: a String, the service account email to authenticate.</li>
168168
* <li>privateKey: a String or byte[], the encoded PKCS#8 encrypted key</li>
169-
* <li>endPoint: optional String, a host with optional port. e.g. "example.com" or "example.com:443".</li>
169+
* <li>endpoint: optional String, a host with optional port. e.g. "example.com" or "example.com:443".</li>
170+
* </ul>
171+
* <p>
172+
* For "kmip", the properties are:
173+
* </p>
174+
* <ul>
175+
* <li>endpoint: a String, the endpoint as a host with required port. e.g. "example.com:443".</li>
170176
* </ul>
171177
* <p>
172178
* For "local", the properties are:

driver-core/src/main/com/mongodb/client/model/vault/DataKeyOptions.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,16 @@ public List<String> getKeyAltNames() {
100100
* <li>endpoint: an optional String, with the host with optional port. Defaults to "cloudkms.googleapis.com".</li>
101101
* </ul>
102102
* <p>
103+
* <p>
104+
* If the kmsProvider is "kmip" the master key is required and must contain the following fields:
105+
* </p>
106+
* <ul>
107+
* <li>keyId: optional String, keyId is the KMIP Unique Identifier to a 96 byte KMIP Secret Data managed object. If keyId is
108+
* omitted, the driver creates a random 96 byte KMIP Secret Data managed object.</li>
109+
* <li>endpoint: a String, the endpoint as a host with required port. e.g. "example.com:443". If endpoint is not provided, it
110+
* defaults to the required endpoint from the KMS providers map.</li>
111+
* </ul>
112+
* <p>
103113
* If the kmsProvider is "local" the masterKey is not applicable.
104114
* </p>
105115
* @return the master key document

0 commit comments

Comments
 (0)