OpenSSL unable to load Public Key

后端 未结 4 1547
忘了有多久
忘了有多久 2021-02-04 11:36

Trying to encrypt a text message via command line on OSX Yosomite 10.10.2

Created public .pem key like this:

ssh-keygen -f ~/.ssh/id_rsa.pub         


        
4条回答
  •  再見小時候
    2021-02-04 12:31

    I had same problem when I was extracting public key from certificate.

    openssl x509 -pubkey -noout -in cert.crt > pubKey.pem
    

    Afterwards, I wanted to print information about key with command below.

    openssl rsa -text -pubin -in pubKey.pem
    

    And gets an error: unable to load Public Key

    Solution

    I opened pubKey.pem in notepad++ and in the Encoding menu was UCS-2 LE BOM selected. So I changed it to UTF-8 encoding. Size of pubKey.pem was half of the original one after changing encoding. Then it works like charm.

    Tested in Windows and powershell

提交回复
热议问题