Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

PowerBuilder Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(PowerBuilder) Load Particular CA Certs into a Java KeyStore

Opens a PEM file containing many CA root certificates, and creates a Java keystore containing a subset of the certificates.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

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
li_rc = loo_Jks.ConnectToNewObject("Chilkat_9_5_0.JavaKeyStore")
if li_rc < 0 then
    destroy loo_Jks
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Troots = create oleobject
li_rc = loo_Troots.ConnectToNewObject("Chilkat_9_5_0.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
li_rc = loo_SbDn.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_SbAlias = create oleobject
li_rc = loo_SbAlias.ConnectToNewObject("Chilkat_9_5_0.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.