如何从 .key 和 .crt 文件中获取 .pem 文件? [英] How to get .pem file from .key and .crt files?
问题描述
如何从 SSL 证书创建 PEM 文件?
How can I create a PEM file from an SSL certificate?
这些是我可用的文件:
.crt
server.csr
server.key
推荐答案
您的密钥可能已经采用 PEM 格式,但只是以 .crt 或 .key 命名.
Your keys may already be in PEM format, but just named with .crt or .key.
如果文件内容以 -----BEGIN
开头,并且您可以在文本编辑器中阅读:
If the file's content begins with -----BEGIN
and you can read it in a text editor:
该文件使用 base64,它以 ASCII 可读,而不是二进制格式.证书已经是 PEM 格式.只需将扩展名更改为 .pem.
The file uses base64, which is readable in ASCII, not binary format. The certificate is already in PEM format. Just change the extension to .pem.
如果文件是二进制文件:
对于 server.crt,您将使用
For the server.crt, you would use
openssl x509 -inform DER -outform PEM -in server.crt -out server.crt.pem
对于 server.key,使用 openssl rsa
代替 openssl x509
.
For server.key, use openssl rsa
in place of openssl x509
.
server.key 可能是您的私钥,.crt 文件是返回的、签名的 x509 证书.
The server.key is likely your private key, and the .crt file is the returned, signed, x509 certificate.
如果这是用于 Web 服务器并且您不能指定加载单独的私钥和公钥:
您可能需要连接这两个文件.用于此用途:
You may need to concatenate the two files. For this use:
cat server.crt server.key > server.includesprivatekey.pem
我建议使用includesprivatekey"命名文件,以帮助您管理此文件的权限.
I would recommend naming files with "includesprivatekey" to help you manage the permissions you keep with this file.
这篇关于如何从 .key 和 .crt 文件中获取 .pem 文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!