Sample code for 30+ languages & platforms
AutoIt

Convert PKCS12 / PFX to Java Keystore (JKS)

See more PFX/P12 Examples

Loads a PKCS12 / PFX file and saves it to a Java keystore (JKS) file.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oPfx = ObjCreate("Chilkat.Pfx")

; Load the PKCS12 from a file
$bSuccess = $oPfx.LoadPfxFile("/someDir/my.p12","myPfxPassword")
If ($bSuccess = False) Then
    ConsoleWrite($oPfx.LastErrorText & @CRLF)
    Exit
EndIf

Local $sJksPassword = "myJksPassword"
Local $sAlias = "firstPrivateKeyAlias"

$oJks = ObjCreate("Chilkat.JavaKeyStore")

; Convert to a Java keystore object.
; The jksPassword is the password to be used for the JKS private key entries. 
; It may be the same as the PFX password, but can also be different if desired.
$bSuccess = $oPfx.ToJksObj($sAlias,$sJksPassword,$oJks)
If ($bSuccess = False) Then
    ConsoleWrite($oPfx.LastErrorText & @CRLF)
    Exit
EndIf

; Save the Java keystore to a file.
$bSuccess = $oJks.ToFile($sJksPassword,"/myKeystores/my.jks")
If ($bSuccess <> True) Then
    ConsoleWrite($oJks.LastErrorText & @CRLF)

    Exit
EndIf

ConsoleWrite("Successfully converted PFX to JKS." & @CRLF)