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
(DataFlex) Add Trusted Certificate to JKSAdds a trusted certificate to a Java keystore file.
Use ChilkatAx-win32.pkg Procedure Test Handle hoJks String sJksPassword String sJksPath Boolean iSuccess Variant vCert Handle hoCert String sAlias String sTemp1 // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatJavaKeyStore)) To hoJks If (Not(IsComObjectCreated(hoJks))) Begin Send CreateComObject of hoJks End Move "secret" To sJksPassword Move "/myJksTrustedCerts/cacerts.jks" To sJksPath // Load the Java keystore from a file. Get ComLoadFile Of hoJks sJksPassword sJksPath To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoJks To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatCert)) To hoCert If (Not(IsComObjectCreated(hoCert))) Begin Send CreateComObject of hoCert End // The cert's LoadFrommFile method can load a certificate from // virtually any format. It will automatically determine the format // and load appropriately. Get ComLoadFromFile Of hoCert "/certFiles/myNewTrustedCert.pem" To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoCert To sTemp1 Showln sTemp1 Procedure_Return End // The alias can be anything. It's basically just a label // used within the JKS associated with the entry. It should // be unique among aliases within the JKS file. Move "habanero" To sAlias Get pvComObject of hoCert to vCert Get ComAddTrustedCert Of hoJks vCert sAlias To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoJks To sTemp1 Showln sTemp1 Procedure_Return End // Write the JKS containing the new certificate. Get ComToFile Of hoJks sJksPassword sJksPath To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoJks To sTemp1 Showln sTemp1 Procedure_Return End Showln "Added a trusted certificate to the JKS." End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.