Xojo Plugin
Xojo Plugin
Convert a PFX to a Java KeyStore
See more PFX/P12 Examples
Demonstrates Pfx.ToJksObj, which populates a JavaKeyStore with a JKS representation of the PFX, then writes it to a file.
The file path is relative to the application's current working directory. An absolute path may also be used. Supply the path appropriate to your own environment.
Background. One private-key entry is created for each private key, with certificate chains built from the PFX certificates. The password protects the generated Java KeyStore.
Chilkat Xojo Plugin Downloads
Dim success As Boolean
success = False
Dim pfx As New Chilkat.Pfx
// The file path is relative to the application's current working directory. An absolute path
// may also be used. Supply the path appropriate to your own environment.
// The PFX password should come from a secure source rather than being hard-coded.
Dim password As String
password = "myPfxPassword"
success = pfx.LoadPfxFile("qa_data/identity.pfx",password)
If (success = False) Then
System.DebugLog(pfx.LastErrorText)
Return
End If
// Populate a Java KeyStore (JKS) representation of this PFX. One private-key entry is created for
// each private key, and the PFX certificates are used to build the certificate chains. The 1st
// argument is the alias for the first private-key entry, and the 2nd protects the generated JKS.
// The JKS password should come from a secure source rather than being hard-coded.
Dim jksPassword As String
jksPassword = "myJksPassword"
Dim jks As New Chilkat.JavaKeyStore
success = pfx.ToJksObj("myalias",jksPassword,jks)
If (success = False) Then
System.DebugLog(pfx.LastErrorText)
Return
End If
// The Java KeyStore object can then be written to a .jks file.
success = jks.ToFile(jksPassword,"qa_output/identity.jks")
If (success = False) Then
System.DebugLog(jks.LastErrorText)
Return
End If
System.DebugLog("Wrote a Java KeyStore with " + Str(jks.NumPrivateKeys) + " private key(s).")