Sample code for 30+ languages & platforms
Unicode C

Set the FTP TLS Version and Ciphers

See more FTP Examples

Demonstrates the TLS negotiation properties SslProtocol and SslAllowedCiphers, and reads back the negotiated TlsVersion and TlsCipherSuite after connecting.

Background: SslProtocol sets the allowed (or minimum) TLS version — default lets Chilkat negotiate the best available, while a value like TLS 1.2 or higher enforces a floor for policy compliance. SslAllowedCiphers narrows the offered cipher suites, which most applications should leave at the secure defaults. The read-only TlsVersion and TlsCipherSuite report what was actually agreed, useful for logging and audits.

Chilkat Unicode C Downloads

Unicode C
#include <C_CkFtp2W.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkFtp2W ftp;

    success = FALSE;

    ftp = CkFtp2W_Create();

    CkFtp2W_putHostname(ftp,L"ftp.example.com");
    CkFtp2W_putUsername(ftp,L"myFtpLogin");

    CkFtp2W_putAuthTls(ftp,TRUE);

    //  Normally you would not hard-code the password in source.  You should instead obtain it
    //  from an interactive prompt, environment variable, or a secrets vault.
    CkFtp2W_putPassword(ftp,L"myPassword");

    //  Require at least TLS 1.2.  Accepted values include "default", "TLS 1.3", "TLS 1.2",
    //  "TLS 1.2 or higher", and so on.  "default" lets Chilkat negotiate the best available.
    CkFtp2W_putSslProtocol(ftp,L"TLS 1.2 or higher");

    //  Optionally restrict the cipher suites offered.  Leave empty to use Chilkat's secure defaults.
    CkFtp2W_putSslAllowedCiphers(ftp,L"TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256");

    success = CkFtp2W_Connect(ftp);
    if (success == FALSE) {
        wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp));
        CkFtp2W_Dispose(ftp);
        return;
    }

    //  After connecting, read back what was actually negotiated.
    wprintf(L"Negotiated TLS version: %s\n",CkFtp2W_tlsVersion(ftp));
    wprintf(L"Negotiated cipher suite: %s\n",CkFtp2W_tlsCipherSuite(ftp));

    success = CkFtp2W_Disconnect(ftp);
    if (success == FALSE) {
        wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp));
        CkFtp2W_Dispose(ftp);
        return;
    }



    CkFtp2W_Dispose(ftp);

    }