Sample code for 30+ languages & platforms
AutoIt

Convert PKCS12 / PFX to Java KeyStore

See more Java KeyStore (JKS) Examples

Converts a PKCS12 / PFX file to a Java keystore (JKS) file.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

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

$oJks = ObjCreate("Chilkat.JavaKeyStore")

$oPfx = ObjCreate("Chilkat.Pfx")

Local $sPfxPassword = "secret"

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

Local $sAlias = "someAlias"
Local $sJksPassword = "jksSecret"

;  Add the PKCS12 to the empty Java keystore object:
$bSuccess = $oJks.AddPfx($oPfx,$sAlias,$sJksPassword)
If ($bSuccess <> True) Then
    ConsoleWrite($oJks.LastErrorText & @CRLF)
    Exit
EndIf

;  Write the Java keystore to a file:
$bSuccess = $oJks.ToFile($sJksPassword,"/jksFiles/my.jks")
If ($bSuccess <> True) Then
    ConsoleWrite($oJks.LastErrorText & @CRLF)
Else
    ConsoleWrite("Successfully converted PKCS12 to JKS" & @CRLF)
EndIf