Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
26 changes: 26 additions & 0 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,13 @@ buildvariants:
tasks:
- happy-eyeballs-task-group

- name: tls-cert-password
display_name: "TLS Certificate File Password"
run_on:
- rhel87-small
tasks:
- name: test-tls-cert-password

###############
# Task Groups #
###############
Expand Down Expand Up @@ -1243,6 +1250,25 @@ tasks:
include_expansions_in_env:
- PROJECT_DIRECTORY

- name: "test-tls-cert-password"
commands:
- func: "bootstrap mongo-orchestration"
vars:
MONGODB_VERSION: latest
TOPOLOGY: server
SSL: ssl
- command: subprocess.exec
type: test
params:
working_dir: src
binary: bash
args:
- .evergreen/run-tls-cert-password-test.sh
include_expansions_in_env:
- PROJECT_DIRECTORY
- MONGODB_URI
- DRIVERS_TOOLS

#############
# Functions #
#############
Expand Down
8 changes: 8 additions & 0 deletions .evergreen/run-tls-cert-password-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

set -o errexit

source .evergreen/env.sh

cd etc/tls_cert_password
cargo run
1 change: 1 addition & 0 deletions etc/tls_cert_password/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/target
9 changes: 9 additions & 0 deletions etc/tls_cert_password/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "tls_cert_password"
version = "0.1.0"
edition = "2021"

[dependencies]
mongodb = { path = "../..", features = ["openssl-tls", "cert-key-password"] }
pkcs8 = { version = "0.10.2", features = ["3des", "des-insecure", "sha1-insecure"] }
tokio = "1.43.0"
29 changes: 29 additions & 0 deletions etc/tls_cert_password/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::path::PathBuf;

use mongodb::{
bson::doc,
options::{Tls, TlsOptions},
Client,
};

#[tokio::main]
async fn main() {
let mut certpath = PathBuf::from(std::env::var("DRIVERS_TOOLS").unwrap());
certpath.push(".evergreen/x509gen");
let mut options = mongodb::options::ClientOptions::parse(std::env::var("MONGODB_URI").unwrap())
.await
.unwrap();
options.tls = Some(Tls::Enabled(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're testing parsing elsewhere, I figure setting the options directly gives us slightly more coverage.

TlsOptions::builder()
.ca_file_path(certpath.join("ca.pem"))
.cert_key_file_path(certpath.join("client-pkcs8-encrypted.pem"))
.tls_certificate_key_file_password(b"password".to_vec())
.build(),
));
let client = Client::with_options(options).unwrap();
client
.database("test")
.run_command(doc! {"ping": 1})
.await
.unwrap();
}
4 changes: 2 additions & 2 deletions src/cmap/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@ impl PinnedConnectionHandle {
}
}

/// Retrieve the pinned connection. Will fail if the connection has been unpinned or is still in
/// use.
/// Retrieve the pinned connection. Will fail if the connection has been unpinned or is still
/// in use.
pub(crate) async fn take_connection(&self) -> Result<PooledConnection> {
use tokio::sync::mpsc::error::TryRecvError;
let mut receiver = self.receiver.lock().await;
Expand Down