expression

ClientConnection construction is not authentication

Creating a connection state machine does not complete a TLS handshake. It must exchange records with a peer and finish verification before the application treats the connection as authenticated. This fixture neither connects a socket nor transfers TLS records. External crate example; candidate dependency is not approved for deployment. Expected stdout (not executed): true true Common mistake: Sending sensitive application data simply because the connection object was created.

Formal Syntax & Structure

rust syntaxrust
ClientConnection::new(Arc<ClientConfig>, ServerName)

Working Example

Example Snippetrust
fn main() {    use std::sync::Arc;    use rustls::{ClientConfig, ClientConnection, RootCertStore, pki_types::ServerName};    let cfg = ClientConfig::builder().with_root_certificates(RootCertStore::empty()).with_no_client_auth();    let conn = ClientConnection::new(Arc::new(cfg), ServerName::try_from("api.example.com").unwrap()).unwrap();    println!("{} {}", conn.is_handshaking(), conn.alpn_protocol().is_none());}
Rust Reference