Perl
Chilkat2 Perl
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 Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $socket = Chilkat2::Socket->new;
# Connect to the server using TLS.
my $bTls = 1;
my $maxWaitMs = 5000;
my $success = $socket->Connect('example.com', 5000, $bTls, $maxWaitMs);
if (!$success) {
print $socket->LastErrorText, "\n";
exit;
}
# 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.
$success = $socket->ConvertFromSsl();
if (!$success) {
print $socket->LastErrorText, "\n";
exit;
}
print "Reverted to a plain TCP connection.\n";