expression
ServerName: expected DNS service identity
Supply the expected service name from trusted application configuration. A parsed DNS name is an identity input to the verifier, not evidence that a peer possesses a matching valid certificate. The fixture uses a reserved example domain and performs no DNS lookup. External crate example; candidate dependency is not approved for deployment. Expected stdout (not executed): true Common mistake: Using the name claimed by an untrusted peer as the expected identity.
Formal Syntax & Structure
rust syntaxrust
ServerName::try_from(host: String)Working Example
Example Snippetrust
fn main() { use rustls::pki_types::ServerName; let name = ServerName::try_from(String::from("api.example.com")).unwrap(); println!("{}", matches!(name, ServerName::DnsName(_)));}