Sample code for 30+ languages & platforms
PHP

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 PHP Downloads

Chilkat2 PHP
<?php

use Chilkat2\Socket;

$socket = new Socket();

// Connect to the server using TLS.
$bTls = true;
$maxWaitMs = 5000;
try {
    $socket->Connect('example.com', 5000, $bTls, $maxWaitMs);

    // 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.
    $socket->ConvertFromSsl();
} catch (\Chilkat2\Exception $e) {
    echo $e->getMessage(), "\n";
    exit;
}

echo "Reverted to a plain TCP connection.\n";