[英]How to add .p12 key to Java Spring from .pem file?
I have this 3 files:我有这 3 个文件:
The certificate.crt contains: certificate.crt 包含:
-----BEGIN CERTIFICATE-----
MIIGmzCCBYOgAwIBAg etc
-----END CERTIFICATE-----
The certificate.key contains: certificate.key 包含:
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCA bla bla
-----END RSA PRIVATE KEY-----
And the certificate.pem is more complex, it has:而 certificate.pem 更复杂,它有:
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgk etc etc
-----END PRIVATE KEY-----
-----BEGIN CERTIFICATE-----
MIIGmzCCBYOgAwIBAg etc
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIGBjCCA+6gAwIBAgIR...
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIFdzCCBF+gAwIBAgIQ...
-----END CERTIFICATE-----
So, certificate.pem contains 1 private key (diferent to certificate.key) and 3 certificates (the first is same to certificate.crt)因此,certificate.pem 包含 1 个私钥(不同于 certificate.key)和 3 个证书(第一个与 certificate.crt 相同)
With this files, how can I get a.p12 file to insert into my Java Spring application?有了这些文件,我怎样才能将.p12 文件插入到我的 Java Spring 应用程序中?
I already tried with openssl convert the.pem file to a.p12 file but when I go to https//mydomain.com there is a not secure ssl message.我已经尝试使用 openssl 将 .pem 文件转换为 a.p12 文件,但是当我将 go 转换为 https//mydomain.com 时,会出现一条不安全的 ssl 消息。
I know it's too late but in case, some one will need that in the future.我知道为时已晚,但以防万一,将来有人会需要它。
sudo openssl pkcs12 -export -in certificate.crt -inkey certificate.key -out keystore.p12
Keep attention, that in most cases cert files are protected and reading operations are allowed only for root / sudo users.请注意,在大多数情况下,证书文件受到保护,并且只允许 root / sudo 用户进行读取操作。 To verify that do ->
ls -al
.验证 do ->
ls -al
。
-rw----r-- 1 root root 5717 Jun 13 21:49 certificate.crt
Perform operations using root / sudo privileges or change permissions using chmod/chown. -rw----r-- 1 root root 5717 Jun 13 21:49 certificate.crt
使用 root / sudo 权限执行操作或使用 chmod/chown 更改权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.