Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) FTPS with Mutual TLS Authentication (TLS Client Certificate)Demonstrates how to do mutual TLS authentication (using a client certificate from a .pfx/.p12).
IncludeFile "CkFtp2.pb" IncludeFile "CkCert.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. ftp.i = CkFtp2::ckCreate() If ftp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkFtp2::setCkHostname(ftp, "ftp.example.com") CkFtp2::setCkPort(ftp, 21) ; If using implicit TLS, you probably want port 990.. CkFtp2::setCkPort(ftp, 990) ; Set this to 0 for implicit TLS, otherwise set to 1 for explicit TLS (where port is typically 21). CkFtp2::setCkAuthTls(ftp, 0) ; Set this to 1 for implicit TLS, otherwise set to 0. CkFtp2::setCkSsl(ftp, 1) cert.i = CkCert::ckCreate() If cert.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkCert::ckLoadPfxFile(cert,"qa_data/pfx/example.pfx","pfx_password") If success = 0 Debug CkCert::ckLastErrorText(cert) CkFtp2::ckDispose(ftp) CkCert::ckDispose(cert) ProcedureReturn EndIf ; Use this certificate for our TLS mutually authenticated connection: success = CkFtp2::ckSetSslClientCert(ftp,cert) If success = 0 Debug CkCert::ckLastErrorText(cert) CkFtp2::ckDispose(ftp) CkCert::ckDispose(cert) ProcedureReturn EndIf ; Establish the TLS connection with the FTP server. success = CkFtp2::ckConnectOnly(ftp) If success = 0 Debug CkFtp2::ckLastErrorText(ftp) CkFtp2::ckDispose(ftp) CkCert::ckDispose(cert) ProcedureReturn EndIf ; If a login is required, then login with the FTP account login/password. CkFtp2::setCkUsername(ftp, "myLogin") CkFtp2::setCkPassword(ftp, "myPassword") success = CkFtp2::ckLoginAfterConnectOnly(ftp) If success = 0 Debug CkFtp2::ckLastErrorText(ftp) CkFtp2::ckDispose(ftp) CkCert::ckDispose(cert) ProcedureReturn EndIf ; Do whatever you're doing to do ... ; upload files, download files, etc... ; ..... ; ..... success = CkFtp2::ckDisconnect(ftp) CkFtp2::ckDispose(ftp) CkCert::ckDispose(cert) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.