Skip to content

Commit 96637e8

Browse files
authored
RUST-2112 Test connecting with tlsCertificateKeyFilePassword (#1283)
1 parent 0b44613 commit 96637e8

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

.evergreen/config.yml

+1
Original file line numberDiff line numberDiff line change
@@ -1529,6 +1529,7 @@ functions:
15291529
args:
15301530
- .evergreen/run-tests.sh
15311531
include_expansions_in_env:
1532+
- DRIVERS_TOOLS
15321533
- PROJECT_DIRECTORY
15331534
- OPENSSL
15341535
- SINGLE_MONGOS_LB_URI

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ futures = "0.3"
168168
hex = "0.4"
169169
home = "0.5"
170170
lambda_runtime = "0.6.0"
171+
pkcs8 = { version = "0.10.2", features = ["3des", "des-insecure", "sha1-insecure"] }
171172
pretty_assertions = "1.3.0"
172173
serde = { version = ">= 0.0.0", features = ["rc"] }
173174
serde_json = "1.0.64"

src/client/options/test.rs

+36
Original file line numberDiff line numberDiff line change
@@ -361,3 +361,39 @@ fn unix_domain_socket_not_allowed() {
361361
"{message}"
362362
);
363363
}
364+
365+
#[cfg(feature = "cert-key-password")]
366+
#[tokio::test]
367+
async fn tls_cert_key_password_connect() {
368+
use std::path::PathBuf;
369+
370+
use bson::doc;
371+
372+
use crate::{
373+
options::TlsOptions,
374+
test::{get_client_options, log_uncaptured},
375+
};
376+
377+
use super::Tls;
378+
379+
let mut options = get_client_options().await.clone();
380+
if !matches!(options.tls, Some(Tls::Enabled(_))) {
381+
log_uncaptured("Skipping tls_cert_key_password_connect: tls not enabled");
382+
return;
383+
}
384+
let mut certpath = PathBuf::from(std::env::var("DRIVERS_TOOLS").unwrap());
385+
certpath.push(".evergreen/x509gen");
386+
options.tls = Some(Tls::Enabled(
387+
TlsOptions::builder()
388+
.ca_file_path(certpath.join("ca.pem"))
389+
.cert_key_file_path(certpath.join("client-pkcs8-encrypted.pem"))
390+
.tls_certificate_key_file_password(b"password".to_vec())
391+
.build(),
392+
));
393+
let client = Client::with_options(options).unwrap();
394+
client
395+
.database("test")
396+
.run_command(doc! {"ping": 1})
397+
.await
398+
.unwrap();
399+
}

0 commit comments

Comments
 (0)