Skip to content

Commit

Permalink
Add code sample showing how to use it
Browse files Browse the repository at this point in the history
  • Loading branch information
djc authored and complexspaces committed Jan 24, 2024
1 parent 578952e commit 39b7d8f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ On most platforms, no setup should be required beyond adding the dependency via
rustls-platform-verifier = "0.1"
```

To get a rustls `ClientConfig` configured to use the platform verifier use:

```rust
let config = rustls_platform_verifier::tls_config();
```

If you want to adapt the configuration, you can build the `ClientConfig` like this:

```rust
use std::sync::Arc;
use rustls::ClientConfig;
use rustls_platform_verifier::Verifier;

let mut config = ClientConfig::builder()
.dangerous() // The `Verifier` we're using is actually safe
.with_custom_certificate_verifier(Arc::new(Verifier::new()))
.with_no_client_auth();
```

### Android
Some manual setup is required, outside of `cargo`, to use this crate on Android. In order to
use Android's certificate verifier, the crate needs to call into the JVM. A small Kotlin
Expand Down

0 comments on commit 39b7d8f

Please sign in to comment.