How to save public key from a certificate in .pem format

后端 未结 2 1312
傲寒
傲寒 2020-12-02 05:37

I am using the below openssl command for storing my public key into a .pem file.

openssl> x509 -in E:/mycert.pem -pubkey  -out E:/mypubkey.pem
         


        
2条回答
  •  再見小時候
    2020-12-02 06:12

    There are a couple ways to do this.

    First, instead of going into openssl command prompt mode, just enter everything on one command line from the Windows prompt:

    E:\> openssl x509 -pubkey -noout -in cert.pem  > pubkey.pem
    

    If for some reason, you have to use the openssl command prompt, just enter everything up to the ">". Then OpenSSL will print out the public key info to the screen. You can then copy this and paste it into a file called pubkey.pem.

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

    Output will look something like this:

    -----BEGIN PUBLIC KEY-----
    MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAryQICCl6NZ5gDKrnSztO
    3Hy8PEUcuyvg/ikC+VcIo2SFFSf18a3IMYldIugqqqZCs4/4uVW3sbdLs/6PfgdX
    7O9D22ZiFWHPYA2k2N744MNiCD1UE+tJyllUhSblK48bn+v1oZHCM0nYQ2NqUkvS
    j+hwUU3RiWl7x3D2s9wSdNt7XUtW05a/FXehsPSiJfKvHJJnGOX0BgTvkLnkAOTd
    OrUZ/wK69Dzu4IvrN4vs9Nes8vbwPa/ddZEzGR0cQMt0JBkhk9kU/qwqUseP1QRJ
    5I1jR4g8aYPL/ke9K35PxZWuDp3U0UPAZ3PjFAh+5T+fc7gzCs9dPzSHloruU+gl
    FQIDAQAB
    -----END PUBLIC KEY-----
    

提交回复
热议问题