Rust
Rust
Revert a TLS Connection to Plain TCP
See more Socket/SSL/TLS Examples
Demonstrates Socket.ConvertFromSsl, which ends the TLS layer while leaving the underlying TCP connection open for subsequent unencrypted communication.
Background. This is the reverse of a STARTTLS-style upgrade and is valid only while TLS is currently active on the connection.
Chilkat Rust Downloads
let socket = chilkat::Socket::new();
// Connect to the server using TLS.
let b_tls = true;
let max_wait_ms = 5000;
if socket.connect("example.com", 5000, b_tls, max_wait_ms).is_err() {
println!("{}", socket.last_error_text());
return;
}
// End the TLS layer while keeping the underlying TCP connection open for subsequent unencrypted
// communication. This is the reverse of a STARTTLS-style upgrade and is valid only while TLS is
// active.
if socket.convert_from_ssl().is_err() {
println!("{}", socket.last_error_text());
return;
}
println!("Reverted to a plain TCP connection.");