[英]How to extract public key and private key from .key file?
I have a file server.key generated by openssl genrsa -out server.key 2048
, which contains both public and private key. 我有一个由openssl genrsa -out server.key 2048
生成的文件server.key,其中包含公钥和私钥。
I searched and fount that I can get public key by openssl rsa -in server.key -pubout -out key.pub
我搜索并发现可以通过openssl rsa -in server.key -pubout -out key.pub
获取公共密钥
How can I get private key from server.key? 如何从server.key获取私钥?
the .key file corresponds to the private key itself. .key文件对应于私钥本身。 If you open your .key file in a text editor you would see that they have -----BEGIN RSA PRIVATE KEY-----
as the prefix and -----END RSA PRIVATE KEY-----
as the suffix. 如果在文本编辑器中打开.key文件,您会看到它们以-----BEGIN RSA PRIVATE KEY-----
作为前缀,以-----END RSA PRIVATE KEY-----
作为前缀后缀。 See below for example: 参见以下示例:
-----BEGIN RSA PRIVATE KEY-----
MIIEogIBAAKCAQEAr/8dgslQvZLyDnPnBVJbihYjhPw6hUuCH1tKop5RitQuob4r
i4ixAhNyrjB3dmO39o8cG56/kb1MHszt256476LGW20Q3s902Nckc4yYqaA02XuE
...
...
rG8D6oIoim5XwtS68fHJpfvciuuE/TQcnS4Ek04jkReP1EXv2hp4CTAZ4l5Tm4HJ
oDmCiSOsQE/YjiyQp5eGFadqosOZZFU7k+8ipKIstr71kEQRiLE=
-----END RSA PRIVATE KEY-----
The command that you shared generates a public key pair from the existing private key. 您共享的命令从现有私钥生成公钥对。
openssl rsa -in server.key -pubout -out key.pub
HTH 高温超导
据我了解,您可以使用openssl rsa -in server.pem -pubout > server.pub
从私钥生成公钥。
@Sato server.key是私钥,但是如果您要查看私钥文件的内容,请使用以下命令:
openssl rsa -noout -text -in server.key
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.