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) Load Particular CA Certs into a Java KeyStoreOpens a PEM file containing many CA root certificates, and creates a Java keystore containing a subset of the certificates.
integer li_rc oleobject loo_Jks oleobject loo_Troots integer li_Success oleobject loo_SbDn oleobject loo_SbAlias integer li_CaseSensitive integer i integer li_NumCerts integer li_NumAdded oleobject loo_Cacert integer li_NumJksCerts // 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 loo_Troots = create oleobject // Use "Chilkat_9_5_0.TrustedRoots" for versions of Chilkat < 10.0.0 li_rc = loo_Troots.ConnectToNewObject("Chilkat.TrustedRoots") // Load certificates from a file. li_Success = loo_Troots.LoadCaCertsPem("qa_data/curl_cacert.pem") if li_Success <> 1 then Write-Debug loo_Troots.LastErrorText destroy loo_Jks destroy loo_Troots return end if loo_SbDn = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbDn.ConnectToNewObject("Chilkat.StringBuilder") loo_SbAlias = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbAlias.ConnectToNewObject("Chilkat.StringBuilder") li_CaseSensitive = 0 i = 0 li_NumCerts = loo_Troots.NumCerts li_NumAdded = 0 do while (i < li_NumCerts) loo_Cacert = loo_Troots.GetCert(i) loo_SbDn.Clear() loo_SbDn.Append(loo_Cacert.SubjectDN) if loo_SbDn.Contains("Entrust.net",li_CaseSensitive) = 1 then Write-Debug loo_Cacert.SubjectDN // The alias is an arbitrary unique string for each cert in the JKS. loo_SbAlias.Clear() loo_SbAlias.Append("cacert_") loo_SbAlias.AppendInt(i + 1) loo_Jks.AddTrustedCert(loo_Cacert,loo_SbAlias.GetAsString()) li_NumAdded = li_NumAdded + 1 end if destroy loo_Cacert i = i + 1 loop // Verify the number of certs in the JKS equals the number we added. li_NumJksCerts = loo_Jks.NumTrustedCerts Write-Debug "NumTrustedCerts = " + string(li_NumJksCerts) if li_NumJksCerts <> li_NumAdded then Write-Debug "Something is amiss!" destroy loo_Jks destroy loo_Troots destroy loo_SbDn destroy loo_SbAlias return end if // Save the JKS. li_Success = loo_Jks.ToFile("myPassword","qa_data/jks/entrust_caCerts.jks") if li_Success <> 1 then Write-Debug loo_Jks.LastErrorText destroy loo_Jks destroy loo_Troots destroy loo_SbDn destroy loo_SbAlias return end if Write-Debug "Success." // The output of this program when tested was: // C=US, O=Entrust.net, OU=www.entrust.net/CPS incorp. by ref. (limits liab.), OU=(c) 1999 Entrust.net Limited, CN=Entrust.net Secure Server Certification Authority // O=Entrust.net, OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.), OU=(c) 1999 Entrust.net Limited, CN=Entrust.net Certification Authority (2048) // C=US, O="Entrust, Inc.", OU=www.entrust.net/CPS is incorporated by reference, OU="(c) 2006 Entrust, Inc.", CN=Entrust Root Certification Authority // NumTrustedCerts = 3 // Success. destroy loo_Jks destroy loo_Troots destroy loo_SbDn destroy loo_SbAlias |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.