美文网首页
RSA openssl操作命令

RSA openssl操作命令

作者: JarhomChen | 来源:发表于2018-12-08 15:52 被阅读3次

1、证书格式转换和加解密

命令 含义
genrsa 生成并输入一个RSA私钥
rsautl 使用RSA密钥进行加密、解密、签名和验证等运算
rsa 处理RSA密钥的格式转换等问题

  • 生成私钥2048位
    openssl genrsa -out private.pem 2048

  • 通过私钥导出公钥
    openssl rsa -in private.pem -pubout -out public.pem

  • 将私钥转成明文
    openssl rsa -in private.pem -text -out private.txt


  • 使用公钥进行加密
    openssl rsautl -encrypt -in msg.txt -inkey public.pem -pubin -out enc.txt

  • 使用私钥进行解密
    openssl rsautl -decrypt -in enc.txt -inkey private.pem -out dec.txt


  • 使用私钥进行签名
    openssl rsautl -sign -in msg.txt -inkey private.pem -out enc.txt

  • 使用公钥进行验证
    openssl rsautl -verify -in enc.txt -inkey public.pem -pubin -out dec.txt

2、创建自签名证书(带通配符*的SSL证书一年能省好多大洋)

1)生成CSR(证书签名请求)

openssl req -new -key private.pem -out domain.csr
说明:CSR包含您的公钥证书,需要依次输入国家,地区,城市,组织,组织单位,Common Name和Email。其中Common Name,可以写自己的名字或者域名,如果要支持https,Common Name应该与域名保持一致,否则会引起浏览器警告。

2)根据CSR生成自签名证书

openssl x509 -req -days 365 -in domain.csr -signkey private.pem -out domain.crt
说明:crt上有证书持有人的信息,持有人的公钥,以及签署者的签名等信息。当用户安装了证书之后,便意味着信任了这份证书,同时拥有了其中的公钥。证书上会说明用途,例如服务器认证,客户端认证,或者签署其他证书。当系统收到一份新的证书的时候,证书会说明,是由谁签署的。如果这个签署者确实可以签署其他证书,并且收到证书上的签名和签署者的公钥可以对上的时候,系统就自动信任新的证书。

3)附加

根据私钥,csr证书,提取p12私钥, 需要设置密码
openssl pkcs12 -export -out p.p12 -inkey private.pem -in domain.crt

根据证书 导出代码可用的 der格式
openssl x509 -outform der -in domain.crt -out domain.der

相关文章

  • RSA openssl操作命令

    1、证书格式转换和加解密 生成私钥2048位openssl genrsa -out private.pem 204...

  • OpenSSL生成公私钥

    1、生成私钥 命令行输入openssl,进入openssl界面,输入: genrsa -out rsa_priva...

  • RSA加密

    Mac系统内置OpenSSL(开源加密库), Mac终端可以直接使用OpenSSL进行RSA的命令运行.opens...

  • RSA 密码代码演示

    openssl 操作RSA公私钥 RSA加解密相关API 最常用的是 PKICSIPADDING 有 生成和导入 ...

  • Linux 命令操作

    1.VIM常用命令 2.生成RSA公钥、秘钥 生成私钥openssl genrsa -out rsa_privat...

  • 使用openssl实现RSA非对称加密

    生成公钥私钥 使用命令生成私钥 openssl genrsa -out rsa_private_key.pem 2...

  • OpenSSL(一)

    OpenSSL的 genrsa 命令用于生成新的RSA私钥。生成一个RSA私人密钥涉及找到两个大的素数,每个大约一...

  • RSA填充方式

    一、 RSA填充方式 二、Openssl 中关于RSA填充部分的代码(路径 : openssl/crypto/rs...

  • Android-Openssl创建RSA公钥和私钥

    Openssl下载https://oomake.com/download/openssl Android-RSA ...

  • OpenSSL(简易版)

    OpenSSL:开源项目 三个组件: openssl命令: openssl命令 对称加密: openssl命令 单...

网友评论

      本文标题:RSA openssl操作命令

      本文链接:https://www.haomeiwen.com/subject/bjmqhqtx.html