Lua
Lua
Convert PKCS12 / PFX to Java KeyStore
See more Java KeyStore (JKS) Examples
Converts a PKCS12 / PFX file to a Java keystore (JKS) file.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local jks = chilkat.JavaKeyStore.new()
local pfx = chilkat.Pfx.new()
local pfxPassword = "secret"
-- Load a PKCS12 from a file.
local success = pfx:load_pfx_file("/someDir/my.p12", pfxPassword)
if not success then
print(pfx.last_error_text)
return
end
local alias = "someAlias"
local jksPassword = "jksSecret"
-- Add the PKCS12 to the empty Java keystore object:
success = jks:add_pfx(pfx, alias, jksPassword)
if not success then
print(jks.last_error_text)
return
end
-- Write the Java keystore to a file:
success = jks:to_file(jksPassword, "/jksFiles/my.jks")
if not success then
print(jks.last_error_text)
else
print("Successfully converted PKCS12 to JKS")
end