Fork me on GitHub

通过命令行手动生成RSA密钥对

安装openSSL

  • apt-get install openssl
  • apt-get install libssl-dev
  • openssl version -a

生成公私钥

  • 生成私钥 (PKCS#1)

    openssl genrsa -out rsa_private.pem 2048
    
  • 由私钥 (PKCS#1)生成公钥 (PKCS#1)

    openssl rsa -in rsa_private.pem -RSAPublicKey_out -out rsa_public2.pem
    
  • 由私钥 (PKCS#1)生成公钥 (PKCS#8)

    openssl rsa -in rsa_private.pem -pubout -out rsa_public.pem
    
  • 要从 (PKCS#1)转换为 (PKCS#8)

    openssl rsa -RSAPublicKey_in -in rsa_public2.pem -pubout
    
  • 要从 (PKCS#8)转换为 (PKCS#1)

    openssl rsa -pubin -in <filename> -RSAPublicKey_out
    
posted @ 2020-12-08 18:03  逍遥メ风  阅读(558)  评论(0编辑  收藏  举报