输入证书: cert/test.pfx 密码假设为123456
输出证书:cert/test.jks
在cmd下运行:
D:\temp\certtest>java ConvertPKCS12ToJKS
显示
keystore type=PKCS12
alias=[my certificate]
/**
* Convert PKCS12 format digital certificate(treated as a PKCS12 keystore)
* to a JKS format keystore, which could be used in JSSE(Although JSSE has
* a tool to recognize PKCS12, internally it's using JKS format).
*/
import java.security.KeyStore;
import java.security.Key;
import java.security.cert.Certificate;
import java.io.*;
import java.util.*;
public class ConvertPKCS12ToJKS
{
//certificate store format
public static final String PKCS12 = "PKCS12";
public static final String JKS = "JKS";
// PKCS12 keystore properties
public static final String INPUT_KEYSTORE_FILE = "cert/test.pfx"; //"cert/dev_coo1.p12";
public static final String KEYSTORE_PASSWORD = "123456"; //"123";
// JKS output file
public static final String OUTPUT_KEYSTORE_FILE = "cert/test.jks";
public static void main(String[] args)
{
try
{
KeyStore inputKeyStore = KeyStore.getInstance("PKCS12");
FileInputStream fis = new FileInputStream(INPUT_KEYSTORE_FILE);
// If the keystore password is empty(""), then we have to set
// to null, otherwise it won't work!!!
char[] nPassword = null;
if ((KEYSTORE_PASSWORD == null) || KEYSTORE_PASSWORD.trim().equals(""))
{
nPassword = null;
}
else
{
nPassword = KEYSTORE_PASSWORD.toCharArray();
}
inputKeyStore.load(fis, nPassword);
fis.close();
System.out.println("keystore type=" + inputKeyStore.getType());
//----------------------------------------------------------------------
// get a JKS keystore and initialize it.
KeyStore outputKeyStore = KeyStore.getInstance("JKS");
outputKeyStore.load(null, "changeit".toCharArray());
// Now we loop all the aliases, we need the alias to get keys.
// It seems that this value is the "Friendly name" field in the
// detals tab <-- Certificate window <-- view <-- Certificate
// Button <-- Content tab <-- Internet Options <-- Tools menu
// In MS IE 6.
Enumeration enum = inputKeyStore.aliases();
while (enum.hasMoreElements()) // we are readin just one certificate.
{
String keyAlias = (String)enum.nextElement();
System.out.println("alias=[" + keyAlias + "]");
if (inputKeyStore.isKeyEntry(keyAlias))
{
Key key = inputKeyStore.getKey(keyAlias, nPassword);
Certificate[] certChain = inputKeyStore.getCertificateChain(keyAlias);
outputKeyStore.setKeyEntry("dev", key, "changeit".toCharArray(), certChain);
}
}
FileOutputStream out = new FileOutputStream(OUTPUT_KEYSTORE_FILE);
outputKeyStore.store(out, nPassword);
out.close();
}
catch (Exception e)
{
e.printStackTrace();
}
}
}
分享到:
相关推荐
PKCS12与JKS格式转换器,提供pkcs12文件转换成jks文件,可以选择源文件位置,和转换后文件存储位置。
\androidstudio\androidstudio_work\CommonDemo\app\fast_keystore.jks -destkeystore E:\androidstudio\androidstudio_work\CommonDemo\app\fast_keystore.jks -deststoretype pkcs12” 迁移到行业标准格式 PKCS12...
将jks文件生成pfx文件的工具,亲测可以使用。 例如: JKS2PFX server.jks 123456 tomcat exportfile c:\progra~1\Java\jre1.5.0_06\bin 该命令将server.jks中别名为tomcat...openssl pkcs12 -info -in exportfile.pfx
1. cer格式——>JKS (keytool 为JDK自带的,可以在bin目录下找到) ...OpenSSL> pkcs12 –in d:\tomcatclient.p12 –out d:\key.pem 4. cer格式——>pem x509 –in d:\wer.cer –inform –out d:\ope.pem
C:\Sun\jwsdp-2.0\xws-security\bin\pkcs12import.bat pkcs12import -file server.p12 -alias server -keystore server.jks •查看server.jks 里面的证书记录: keytool -list -v -keystore server.jks
使用keytool.exe,将jks格式证书转换成pfx格式证书。由于本工具未包括keytool.exe 需要安装jdk 才能够正常运行。 没有积分的用户可以根据以下命令行手动导出(keytool.exe 可以在jdk安装目录中找到): keytool.exe ...
其以二进制格式存储,在windows中可以直接导入到密钥区,注意,PKCS#12的密钥库保护密码同时也用于保护Key。 UBER 比较特别,当密码是通过命令行提供的时候,它只能跟keytool交互。整个keystore是通过PBE/SHA1/...
文档主要包括三部分内容 ... openssl生成的pem格式证书转换为p12(pfx/pkcs12)、jks格式证书 keytool生成的jks证书转换为 p12(pfx/pkcs12)、pem格式证书 4。证书安全说明 常用crt/cer、pem、p12/pfx、jks解释说明
建议使用 “keytool -importkeystore -srckeystore E:\lvchuang\lvchuang.jks -destkeystore E:\lvchuang\lvchuang.jks -deststoretype pkcs12” 迁移到行业标准格式 PKCS12。 谈出来的图片如图: 解决的方法其实很...
Java KeyStore 文件查看器 支持JKS PKCS12等文件格式的查看
1. 如果提供的是.keystore格式:(jks也可以用这种方式转换)首先把证书转换成pkcs12格式keytool -importkeystore -src
Android签名工具 常用的android的签名工具有:jarsigner 和apksigner。jarsigner使用keystore文件,apksigner使用pk8+x509.pem。 什么是.pem和.pk8文件 .pem 在android对apk签名的...1.将keystore文件转换为pkcs12格式
Tomcat 目前只能操作 JKS、PKCS11、PKCS12 格式的密钥存储库。JKS 是 Java 标准的“Java 密钥存储库”格式,是通过 keytool 命令行工具创建的。该工具包含在 JDK 中。PKCS12 格式一种互联网标准,可以通过 OpenSSL ...
直接使用,别名 PKCS12 密码123456 场景:提供了的Android系统进行产品开发 或者提供系统级别以及系统权限的app应用 1.工具介绍: A. platform.pk8 platform.x509.pem 这2个Android源系统级别的秘钥 B. storeFile....
证书制作包,签名工具包,C#等。里面包含一组实用的工具:makecet,signcode,makectl,makecat,certmgr,cert2spc,cabarc等。
建议使用 “keytool -importkeystore -srckeystore E:\xxxxxx- pkcs12” 迁移到行业标准格式PKCS12 一下步骤经过android studio3.5.2测试通过。 一下命令通过mac终端执行 1.生成签名文件 keytool -genkey -alias ***...
密钥库资源管理器 KeyStore Explorer是Java命令行实用程序...以多种格式导入和导出密钥和证书:PKCS#12,PKCS#8,PKCS#7,DER / PEM X.509证书文件,Microsoft PVK,SPC,PKI路径,OpenSSL 生成,查看和签名
golang解析数字证书 PKCS#1 PKCS#8格式的私钥
1.PKCS12 2.JKS 查看证书库内容: 分为私钥别名和证书别名 生成证书的同时会生成三个文件: 1.私钥文件(pem) 2.证书文件(pem) 3.密钥库文件--jks或者p12(pfx)后者IE可用 版权所有,蓝调工作室 作者:Rocky Lee 联系方式...
Start your own PKI and create all kinds of certificates, requests or CRLs Import and export them in any format like PEM, DER, PKCS#7, PKCS#12 编辑JKS文件、PKCS#12、PFX文件,