Visual FoxPro
Visual FoxPro
Add Trusted Certificate to JKS
See more Java KeyStore (JKS) Examples
Adds a trusted certificate to a Java keystore file.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loJks
LOCAL lcJksPassword
LOCAL lcJksPath
LOCAL loCert
LOCAL lcAlias
lnSuccess = 0
* This requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loJks = CreateObject('Chilkat.JavaKeyStore')
lcJksPassword = "secret"
lcJksPath = "/myJksTrustedCerts/cacerts.jks"
* Load the Java keystore from a file.
lnSuccess = loJks.LoadFile(lcJksPassword,lcJksPath)
IF (lnSuccess <> 1) THEN
? loJks.LastErrorText
RELEASE loJks
CANCEL
ENDIF
loCert = CreateObject('Chilkat.Cert')
* The cert's LoadFrommFile method can load a certificate from
* virtually any format. It will automatically determine the format
* and load appropriately.
lnSuccess = loCert.LoadFromFile("/certFiles/myNewTrustedCert.pem")
IF (lnSuccess <> 1) THEN
? loCert.LastErrorText
RELEASE loJks
RELEASE loCert
CANCEL
ENDIF
* 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.
lcAlias = "habanero"
lnSuccess = loJks.AddTrustedCert(loCert,lcAlias)
IF (lnSuccess <> 1) THEN
? loJks.LastErrorText
RELEASE loJks
RELEASE loCert
CANCEL
ENDIF
* Write the JKS containing the new certificate.
lnSuccess = loJks.ToFile(lcJksPassword,lcJksPath)
IF (lnSuccess <> 1) THEN
? loJks.LastErrorText
RELEASE loJks
RELEASE loCert
CANCEL
ENDIF
? "Added a trusted certificate to the JKS."
RELEASE loJks
RELEASE loCert