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
(PowerBuilder) Add Trusted Certificate to JKSAdds a trusted certificate to a Java keystore file.
integer li_rc oleobject loo_Jks string ls_JksPassword string ls_JksPath integer li_Success oleobject loo_Cert string ls_Alias // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Jks = create oleobject // Use "Chilkat_9_5_0.JavaKeyStore" for versions of Chilkat < 10.0.0 li_rc = loo_Jks.ConnectToNewObject("Chilkat.JavaKeyStore") if li_rc < 0 then destroy loo_Jks MessageBox("Error","Connecting to COM object failed") return end if ls_JksPassword = "secret" ls_JksPath = "/myJksTrustedCerts/cacerts.jks" // Load the Java keystore from a file. li_Success = loo_Jks.LoadFile(ls_JksPassword,ls_JksPath) if li_Success <> 1 then Write-Debug loo_Jks.LastErrorText destroy loo_Jks return end if loo_Cert = create oleobject // Use "Chilkat_9_5_0.Cert" for versions of Chilkat < 10.0.0 li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert") // The cert's LoadFrommFile method can load a certificate from // virtually any format. It will automatically determine the format // and load appropriately. li_Success = loo_Cert.LoadFromFile("/certFiles/myNewTrustedCert.pem") if li_Success <> 1 then Write-Debug loo_Cert.LastErrorText destroy loo_Jks destroy loo_Cert return end if // 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. ls_Alias = "habanero" li_Success = loo_Jks.AddTrustedCert(loo_Cert,ls_Alias) if li_Success <> 1 then Write-Debug loo_Jks.LastErrorText destroy loo_Jks destroy loo_Cert return end if // Write the JKS containing the new certificate. li_Success = loo_Jks.ToFile(ls_JksPassword,ls_JksPath) if li_Success <> 1 then Write-Debug loo_Jks.LastErrorText destroy loo_Jks destroy loo_Cert return end if Write-Debug "Added a trusted certificate to the JKS." destroy loo_Jks destroy loo_Cert |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.