Sample code for 30+ languages & platforms
Delphi ActiveX

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 Delphi ActiveX Downloads

Delphi ActiveX
var
success: Integer;
socket: TChilkatSocket;
bTls: Integer;
maxWaitMs: Integer;

begin
success := 0;

socket := TChilkatSocket.Create(Self);

//  Connect to the server using TLS.
bTls := 1;
maxWaitMs := 5000;
success := socket.Connect('example.com',5000,bTls,maxWaitMs);
if (success = 0) then
  begin
    Memo1.Lines.Add(socket.LastErrorText);
    Exit;
  end;

//  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 = 0) then
  begin
    Memo1.Lines.Add(socket.LastErrorText);
    Exit;
  end;
Memo1.Lines.Add('Reverted to a plain TCP connection.');