Skip to content

Commit

Permalink
Update docs in rustls and native_tls mods
Browse files Browse the repository at this point in the history
  • Loading branch information
rustworthy committed Nov 3, 2024
1 parent 4fcd876 commit 2292e34
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
7 changes: 4 additions & 3 deletions src/tls/native_tls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,10 @@ where
{
/// Create a new TLS connection on an existing stream.
///
/// Internally creates a `ClientConfig` with an empty root certificates store and no client
/// authentication. Use [`new`](TlsStream::new) for a customized `TlsConnector`.
/// Create a new TLS connection on an existing stream.
/// Internally, creates a [`TlsConnector`](https://docs.rs/tokio-native-tls/latest/tokio_native_tls/native_tls/struct.TlsConnector.html)
/// with default settings.
///
/// Use [`new`](TlsStream::new) for a customized connector.
pub async fn default(stream: S, hostname: String) -> io::Result<Self> {
let connector = TlsConnector::builder()
.build()
Expand Down
20 changes: 12 additions & 8 deletions src/tls/rustls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,12 @@ impl TlsStream<TokioTcpStream> {
///
/// If `url` is given, but does not specify a port, it defaults to 7419.
///
/// Internally creates a `ClientConfig` with an _empty_ root certificates store and _no client
/// authentication_. Use [`with_client_config`](TlsStream::with_client_config)
/// or [`with_connector`](TlsStream::with_connector) for customized
/// `ClientConfig` and `TlsConnector` accordingly.
/// Internally, creates a [`ClientConfig`](https://docs.rs/rustls/latest/rustls/client/struct.ClientConfig.html)
/// with an _empty_ root certificates store and _no client authentication_.
///
/// Use [`with_client_config`](TlsStream::with_client_config) or [`with_connector`](TlsStream::with_connector)
/// for customized `ClientConfig` and [`TlsConnector`](https://docs.rs/tokio-rustls/latest/tokio_rustls/struct.TlsConnector.html)
/// accordingly.
pub async fn connect() -> Result<Self, Error> {
let config = ClientConfig::builder()
.with_root_certificates(RootCertStore::empty())
Expand All @@ -77,10 +79,12 @@ impl TlsStream<TokioTcpStream> {
TlsStream::with_connector(connector, Some(addr)).await
}

/// Create a new TLS connection over TCP using native certificates.
/// Create a new TLS connection over TCP using platform certificates.
///
/// Unlike [`TlsStream::connect`], creates a root certificates store populated
/// with the certificates loaded from a platform-native certificate store.
///
/// Similarly to [`TlsStream::connect`], no client authentication will be used.
pub async fn connect_with_native_certs_to(addr: &str) -> Result<Self, Error> {
let config = ClientConfig::with_platform_verifier();

Check warning on line 89 in src/tls/rustls.rs

View check run for this annotation

Codecov / codecov/patch

src/tls/rustls.rs#L89

Added line #L89 was not covered by tests
TlsStream::with_connector(TlsConnector::from(Arc::new(config)), Some(addr)).await
Expand Down Expand Up @@ -115,10 +119,10 @@ where
{
/// Create a new TLS connection on an existing stream.
///
/// Internally creates a `ClientConfig` with an empty root certificates store and no client
/// authentication.
/// Internally, creates a [`ClientConfig`](https://docs.rs/tokio-native-tls/latest/tokio_native_tls/native_tls/struct.TlsConnector.html)
/// with an empty root certificates store and no client authentication.
///
/// Use [`new`](TlsStream::new) for a customized `TlsConnector`.
/// Use [`new`](TlsStream::new) for a customized [`TlsConnector`](https://docs.rs/tokio-rustls/latest/tokio_rustls/struct.TlsConnector.html).
pub async fn default(stream: S, hostname: String) -> io::Result<Self> {
let conf = ClientConfig::builder()
.with_root_certificates(RootCertStore::empty())
Expand Down

0 comments on commit 2292e34

Please sign in to comment.