简体   繁体   English

如何从旧密钥文件中提取公钥以与新私钥一起使用(私钥丢失的密码)

[英]How to extract public key from old key file to use with new private key (lost private key password)

I have a Ubuntu server with .key files for use in https. 我有一个带有.key文件的Ubuntu服务器,可在https中使用。

It's time to renew my certificate which requires that I create a new .csr using a .key file which has a public and private key, but I no longer have the password for the private key which I would have liked to reuse. 是时候更新我的证书了,这要求我使用具有公钥和私钥的.key文件创建一个新的.csr,但是我不再拥有想要重用的私钥密码。 I want to keep the public key the same but have a different private key with a password that I actually have. 我想保持公钥不变,但是拥有一个与我实际拥有的密码不同的私钥。

Several resources have stated that it is possible to calculate a public key from a .key file, but the following steps are not exactly clear. 一些资源指出可以从.key文件中计算公钥,但是以下步骤并不十分清楚。

Here is what I think I want to do: 这是我想做的事情:

  • Get public key from old .key file 从旧的.key文件中获取公钥
  • Generate new key file using said public key and new private key 使用所述公钥和新私钥生成新密钥文件
  • Generate csr 产生csr
  • Get new certificate 获取新证书

Here was one thread I looked at, but there didn't seem to be anything in the format I need: 这是我查看过的一个线程,但似乎没有任何需要的格式:

This one helped: 这个帮助:

A command that worked for me was: 对我有用的命令是:

openssl rsa -in www_website_com.key -pubout -out pubkey.pem

Now the problem is that I don't know the next step or if it is even possible to reuse this separated public key. 现在的问题是我不知道下一步,或者是否有可能再次使用此分离的公钥。

You cannot do this. 你不可以做这个。 By having private key you can restore public key, but not vice versa. 通过拥有私钥,您可以还原公钥,反之亦然。 It is impossible to recreate private key by having only public key. 仅拥有公共密钥是不可能重新创建私有密钥的。 Otherwise, entire public key world would be broken. 否则,整个公钥世界将被破坏。

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

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