[][src]Function libtls::config::parse_protocols

pub fn parse_protocols(protostr: &str) -> Result<u32>

Parse protocol string.

The tls_config_parse_protocols utility function parses a protocol string and returns the corresponding value via the protocols argument. This value can then be passed to the set_protocols method. The protocol string is a comma or colon separated list of keywords. Valid keywords are tlsv1.0, tlsv1.1, tlsv1.2, tlsv1.3, all (all supported protocols), default (an alias for secure), legacy (an alias for all) and secure (currently TLSv1.2 and TLSv1.3). If a value has a negative prefix (in the form of a leading exclamation mark) then it is removed from the list of available protocols, rather than being added to it.

Example

// Parse a list of allowed protocols:
let protocols = config::parse_protocols("tlsv1.1,tlsv1.2").unwrap();
assert_eq!(protocols, TLS_PROTOCOL_TLSv1_1|TLS_PROTOCOL_TLSv1_2);

// The default is to use the `secure` protocols:
let protocols = config::parse_protocols("default").unwrap();
assert_eq!(protocols, TLS_PROTOCOLS_DEFAULT);
assert_ne!(protocols, TLS_PROTOCOLS_ALL);

See also

tls_config_parse_protocols(3)