简体   繁体   English

为 Jenkins HTTPS 将 .pem 和 .key 转换为 .jks

[英]Convert .pem and .key to .jks for Jenkins HTTPS

I have a certificate provided by my company, one .pem file and one .key file as follows:我有我公司提供的证书,一个 .pem 文件和一个 .key 文件如下:

.pem file: .pem 文件:

-----BEGIN CERTIFICATE-----
{THE CERTIFICATE KEY}
-----END CERTIFICATE-----

.key file .key 文件

-----BEGIN PRIVATE KEY-----
{THE KEY}
-----END PRIVATE KEY-----

I need to obtain a .jks file because that's the only format accepted by Jenkins (I'm trying to enable HTTPS)我需要获取一个 .jks 文件,因为这是 Jenkins 接受的唯一格式(我正在尝试启用 HTTPS)

I tried to concatenate the two files and follow the steps described here and here , specifically:我尝试连接这两个文件并按照此处此处描述的步骤进行操作,特别是:

mv cert_private_key.key cert_private_key.pem    
cat cert_private_key.pem cert_public_key.pem | openssl pkcs12 -export -out cert.p12 

as the next step would be to convert the .p12 file to .jks, but the console just hangs or I get an "unable to load private key" / "unable to load certificates"因为下一步是将 .p12 文件转换为 .jks,但控制台只是挂起或者我得到“无法加载私钥”/“无法加载证书”

Any help is much appreciated!任何帮助深表感谢!

openssl pkcs12 -export -out certificate.pkcs12 -in certificate.pem -inkey certificate.key

worked.工作。 Make sure to use the official OpenSSL确保使用官方 OpenSSL

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM