Sample code for 30+ languages & platforms
Classic ASP

Convert PKCS12 / PFX to Java KeyStore

See more Java KeyStore (JKS) Examples

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

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

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

set jks = Server.CreateObject("Chilkat.JavaKeyStore")

set pfx = Server.CreateObject("Chilkat.Pfx")

pfxPassword = "secret"

' Load a PKCS12 from a file.
success = pfx.LoadPfxFile("/someDir/my.p12",pfxPassword)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( pfx.LastErrorText) & "</pre>"
    Response.End
End If

alias = "someAlias"
jksPassword = "jksSecret"

' Add the PKCS12 to the empty Java keystore object:
success = jks.AddPfx(pfx,alias,jksPassword)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( jks.LastErrorText) & "</pre>"
    Response.End
End If

' Write the Java keystore to a file:
success = jks.ToFile(jksPassword,"/jksFiles/my.jks")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( jks.LastErrorText) & "</pre>"
Else
    Response.Write "<pre>" & Server.HTMLEncode( "Successfully converted PKCS12 to JKS") & "</pre>"
End If


%>
</body>
</html>