DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoFtp
String sTemp1
Move False To iSuccess
Get Create (RefClass(cComChilkatFtp2)) To hoFtp
If (Not(IsComObjectCreated(hoFtp))) Begin
Send CreateComObject of hoFtp
End
Set ComHostname Of hoFtp To "ftp.example.com"
Set ComUsername Of hoFtp To "myFtpLogin"
Set ComAuthTls Of hoFtp To 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.
Set ComPassword Of hoFtp To "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.
Set ComSslProtocol Of hoFtp To "TLS 1.2 or higher"
// Optionally restrict the cipher suites offered. Leave empty to use Chilkat's secure defaults.
Set ComSslAllowedCiphers Of hoFtp To "TLS_AES_256_GCM_SHA384,TLS_CHACHA20_POLY1305_SHA256"
Get ComConnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
// After connecting, read back what was actually negotiated.
Get ComTlsVersion Of hoFtp To sTemp1
Showln "Negotiated TLS version: " sTemp1
Get ComTlsCipherSuite Of hoFtp To sTemp1
Showln "Negotiated cipher suite: " sTemp1
Get ComDisconnect Of hoFtp To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoFtp To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure