-
Notifications
You must be signed in to change notification settings - Fork 183
Open
Labels
Description
Versions/Environment
- What version of Rust are you using? - rustc 1.88.0
- What operating system are you using? - macos 15.1.1
- What versions of the driver and its dependencies are you using? (Run
cargo pkgid mongodb
&cargo pkgid bson
) - mongodb@3.2.3, bson@2.15.0 - What version of MongoDB are you using? (Check with the MongoDB shell using
db.version()
) - DocumentDB 5.0.0 - What is your MongoDB topology (standalone, replica set, sharded cluster, serverless)? - replicate set
Describe the bug
Following code:
use std::path::PathBuf;
use mongodb::Client;
use mongodb::options::{AuthMechanism, ClientOptions, Credential, Tls, TlsOptions};
#[tokio::main]
async fn main() {
let uri = "mongodb://localhost:27017/tpch?directConnection=true";
let mut opts = ClientOptions::parse(uri).await.unwrap();
opts.credential = Some(
Credential::builder()
.username("<access_key>".to_string())
.password("<secret_access_key>".to_string())
.source("$external".to_string())
.mechanism(AuthMechanism::MongoDbAws)
.build()
);
let ca_path = PathBuf::from("/Users/krinart/global-bundle.pem");
opts.tls = Some(Tls::Enabled(
TlsOptions::builder()
.ca_file_path(Some(ca_path))
.allow_invalid_hostnames(true)
.build(),
));
let client = Client::with_options(opts).unwrap();
let db = client.database("tpch");
println!("Collections: {:?}", db.list_collection_names().await.unwrap());
}
Returns:
Error { kind: Command(CommandError { code: 73, code_name: "", message: "Command isMaster not supported on $external database.", topology_version: None }), labels: {}, wire_version: None, source: None }
For the context this command works:
AWS_ACCESS_KEY_ID=<> AWS_SECRET_ACCESS_KEY=<> mongosh \
--host localhost \
--port 27017 \
--tls \
--tlsCAFile /Users/krinart/global-bundle.pem \
--tlsAllowInvalidHostnames \
--authenticationDatabase '$external' \
--authenticationMechanism MONGODB-AWS \
tpch