expression
ServerName: IP identity versus DNS identity
An IP literal is represented as an IP identity, not as a DNS name. A certificate for a DNS service is not automatically valid for its address; the verifier uses the corresponding identity type. This example uses a documentation-only IPv4 address. External crate example; candidate dependency is not approved for deployment. Expected stdout (not executed): true Common mistake: Assuming a DNS-name certificate also proves ownership of every IP address it resolves to.
Formal Syntax & Structure
rust syntaxrust
ServerName::try_from("192.0.2.10")Working Example
Example Snippetrust
fn main() { use rustls::pki_types::ServerName; let name = ServerName::try_from("192.0.2.10").unwrap(); println!("{}", matches!(name, ServerName::IpAddress(_)));}