keystore生成、导出p12,cer,crt,.key.pem证书文件格式

1、生成keystore文件

命令行窗口执行如下命令:

keytool -genkey -alias ynhr -keyalg RSA -keysize 1024 -keypass 123456 -validity 36500 -keystore test.keystore -storepass 123456

命令解读:

-alias 别名:ynhr

-keyalg 算法:RSA

-keysize 密码长度:1024

-keypass 私钥访问密码:123456

-validity 有效期:36500天

-keystore 名称:test.keystore

-storepass keystone文件访问密码:123456

在目录下已生成名为:test.keystore 的文件

2、keytool 通过keystone 导出p12文件

keytool -importkeystore -srcstoretype JKS -srckeystore test.keystore -srcstorepass 123456 -srcalias ynhr -srckeypass 123456 -deststoretype PKCS12 -destkeystore test.p12 -deststorepass 123456 -destalias client -destkeypass 123456 -noprompt

继续执行如上命令导出p12私钥文件

3、从p12导出格式为.key的私钥文件

openssl pkcs12 -in test.p12 -nocerts -nodes -out test.key

4、从keystore导出cer公钥证书文件

keytool -export -alias ynhr -keystore test.keystore -rfc -file test.cer

有时候需要.crt格式的文件,调整下格式即可

keytool -export -alias ynhr -keystore test.keystore -rfc -file test.crt

5、导出格式为“pem”的公钥证书文件

5.1、keytool生成keystore的转为PKCS12格式

keytool -importkeystore -srcstoretype JKS -srckeystore test.keystore -srcstorepass 123456 -srcalias ynhr -srckeypass 123456 -deststoretype PKCS12 -destkeystore test.p12 -deststorepass 123456 -destalias test -destkeypass 123456 -noprompt

5.2、opensl 从PKCS12中导出私钥

openssl pkcs12 -in test.p12 -passin pass:123456 -nocerts -out test.private

MAC verified OK

Enter PEM pass phrase:123456

Verifying - Enter PEM pass phrase:123456

5.3、opensl 从私钥导出不带签名的公钥

openssl rsa -in test.private -pubout

Enter pass phrase for client.private:123456

writing RSA key

-----BEGIN PUBLIC KEY-----

MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClREmV3+XLyq23AKA00kYZ0exc

4CcLqhVVgavJckgwLKPKc0F0Rg8J4fKb8JBfIl9qaHa/RWh6MI50y1GKBEub5PWj

JOAwsDhhLKTOD8DU7GXJnDOcwMfFPhfcMvID98l3uK3G9fjviMcKbN3tMlW0vg0D

19msDnNhOpRKqZnULwIDAQAB

-----END PUBLIC KEY-----

6、将公钥证书导入密钥库

keytool -import -v -file bst.cer -keystore miepay.keystore

  • 8
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
keytool platform.x509.pem 文件是一个 X.509 格式的证书文件。在计算机安全领域,X.509 是一种通用的证书标准,用于在公钥加密体系中对实体进行身份验证。 keytool 是一个Java密钥和证书管理工具,用于管理Java密钥库(JKS)中的密钥、证书和可信任的证书颁发机构(CA)。 .platform.x509.pem 文件是基于 X.509 标准的证书文件的命名方式,并且带有.platform前缀,可能表示其是与某个特定平台相关的证书。 使用keytool命令可通过以下方式操作 platform.x509.pem 文件: 1. 导入证书:可以使用 keytool 命令导入指定的证书到 Java 密钥库。例如,可以使用以下命令将 platform.x509.pem 导入到密钥库中: `keytool -importcert -alias mycert -file platform.x509.pem -keystore mykeystore.jks` 2. 查看证书:可以使用 keytool 查看证书的详细信息。例如,可以使用以下命令查看 platform.x509.pem 证书的详细信息: `keytool -printcert -file platform.x509.pem` 3. 导出证书:可以使用 keytool 将密钥库中的证书导出为独立的证书文件。例如,可以使用以下命令将密钥库中名为 mycert 的证书导出为 platform.x509.pem 文件: `keytool -exportcert -alias mycert -file platform.x509.pem -keystore mykeystore.jks` 需要注意的是,以上命令仅为示例,具体的命令参数和使用方法可能会因实际情况而异。在使用 keytool 时,应注意保证密钥库和证书文件的安全,并且遵循最佳实践来管理密钥和证书

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值