-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Windows] Consider adding other store names than "ROOT"
#131
Comments
Out of curiosity, does |
I think we'd need to deeply understand what the various store names actually mean. eg, "Intermediate Certification Authorities" rings alarm bells for me, as trusting those directly would shorten the paths to remove the actually intended issuers. |
Good question, I will try to check once I have access to the environment tomorrow.
Agreed. However, we should consider how the current setup compares to the unix and macos implementations; is the Windows implementation actually comparable to checking the ca-certificates file (and looking for it using Either way, another thing to consider is to perhaps add an environment variable to allow the setting of additional stores, like |
@cpu I wrote the following small program to test, and in my environment passing The test was done using an internal service on SERVER signed by a specific certificate use std::io::{Write, Read};
use std::sync::Arc;
use rustls::ClientConfig;
use rustls_platform_verifier;
use rustls_native_certs;
fn main() {
let pv = std::env::var("PV");
let server = std::env::var("SERVER").unwrap();
let config = if let Ok("1") = pv.as_deref() {
println!("Using platform verifier");
ClientConfig::builder()
.dangerous()
.with_custom_certificate_verifier(Arc::new(rustls_platform_verifier::Verifier::new()))
.with_no_client_auth()
} else {
println!("Using native tls verifier (change by passing setting PV=1)");
let mut roots = rustls::RootCertStore::empty();
let native_certs = rustls_native_certs::load_native_certs().unwrap();
for cert in native_certs {
roots.add(cert).unwrap();
}
ClientConfig::builder()
.with_root_certificates(roots)
.with_no_client_auth()
};
let rc_config = Arc::new(config);
let host = server.clone().try_into().unwrap();
let mut client = rustls::ClientConnection::new(rc_config, host).unwrap();
let mut socket = std::net::TcpStream::connect(&format!("{server}:443")).unwrap();
let mut stream = rustls::Stream::new(&mut client, &mut socket); // Create stream
stream
.write(b"GET / HTTP/1.1\r\nConnection: close\r\n\r\n")
.unwrap();
let mut plaintext = Vec::new();
stream.read_to_end(&mut plaintext).unwrap();
std::io::stdout().write_all(&plaintext).unwrap();
} |
Specifically for Windows (and macOS) I think the platform verifier crate always provides a better solution so unless you have a specific use case for the particular functionality in native-certs, I think you should just use that instead. |
Thanks for testing! That's good news.
I think the right fix is for
Agreed. |
Thanks for linking that issue, it does indeed seem like the solution. I do believe that's the behaviour I needed all along. I'm gonna check a bit more next week, but I simply did not know rustls-platform-verifier existed. |
To be clear, you can use reqwest with the platform verifier crate today: Client::builder()
.use_preconfigured_tls(
rustls_platform_verifier::tls_config_with_provider(Arc::new(
aws_lc_rs::default_provider(),
))
.expect("failed to initialize pre-configured rustls backend"),
) |
Thanks for clarifying, that's a good call out. I meant just in terms of offering features to do this out-of-box ala |
I'm going to close this issue since I think we've reached a conclusion where Thanks! |
Hello, thanks for the good work on rustls!
I'm writing from inside the corporate world where certificates are pushed out on user machines, much like #22. I recently found out that while rustls-native-certs can detect certificates in the
Root
certificate store, it fails to detect all that are needed in my environment.I can open a PR for adding some other stores that are required for my use case, but I wanted to ask the question if it is desirable? Basically a change would look like this (in my case only
CA
needs to be added, but the others might be a good idea):The docs for
CertStore::open_current_user
mentions the store names I have included here, and the source above theCERTIFICATE_STORE_NAMES
go into some detail.The text was updated successfully, but these errors were encountered: