openssl 命令详解

openssl genrsa 命令产生私钥

openssl genrsa 命令是会用来生成 RSA 私有秘钥,不会生成公钥,因为公钥提取自私钥。生成时是可以指定私钥长度和密码保护。

如果需要查看公钥或生成公钥,可以使用 openssl rsa 命令。

命令语法:

openssl  genrsa [-out filename] [-passout arg] [-f4] [-3] [-rand file(s)] [-engine id] [numbits] [-des] [-des3] [-idea]

  openssl genrsa [-out filename] [-passout arg] [-aes128] [-aes192] [-aes256] [-camellia128] [-camellia192] [-camellia256] [-des]

       [-des3] [-idea] [-f4] [-3] [-rand file(s)] [-engine id] [numbits]

penssl genrsa ?

openssl genrsa ?

usage: genrsa [args] [numbits]

 -des            encrypt the generated key with DES in cbc mode

 -des3           encrypt the generated key with DES in ede cbc mode (168 bit key)

 -idea           encrypt the generated key with IDEA in cbc mode

 -seed

                 encrypt PEM output with cbc seed

 -aes128, -aes192, -aes256

                 encrypt PEM output with cbc aes

 -camellia128, -camellia192, -camellia256

                 encrypt PEM output with cbc camellia

 -out file       output the key to 'file

 -passout arg    output file pass phrase source

 -f4             use F4 (0x10001) for the E value

 -3              use 3 for the E value

 -engine e       use engine e, possibly a hardware device.

 -rand file:file:...

                 load the file (or the files in the directory) into

                 the random number generator

[root@ecs-be9a CA]#

openssl genrsa -des3 -out test1.key 2048 

生成私钥,私钥中含有公钥,如果需要公钥,需要单独提取公钥

从私钥导出公钥

从私钥导出公钥方法:

openssl rsa [-inform PEM|NET|DER] [-outform PEM|NET|DER] [-in filename] [-passin arg] [-out filename] [-passout arg] [-sgckey]

       [-aes128] [-aes192] [-aes256] [-camellia128] [-camellia192] [-camellia256] [-des] [-des3] [-idea] [-text] [-noout] [-modulus]

       [-check] [-pubin] [-pubout] [-RSAPublicKey_in] [-RSAPublicKey_out] [-engine id]

openssl req 命令 

openssl req 命令详解 :openssl req命令主要的功能有,生成证书请求文件, 查看验证证书请求文件,还有就是生成自签名证书。生成证书请求需要什么:申请者需要将自己的信息及其公钥放入证书请求中。但在实际操作过程中,

所需要提供的是私钥而非公钥,因为它会自动从私钥中提取公钥。另外,还需要将提供的数据进行数字签名(使用单向加密),保证该证书请求文件的完整性和一致性,防止他人盗取后进行篡改

    -new    :说明生成证书请求文件

     -x509   :说明生成自签名证书

     -key    :指定已有的秘钥文件生成秘钥请求,只与生成证书请求选项-new配合。

     -newkey :-newkey是与-key互斥的,-newkey是指在生成证书请求或者自签名证书的时候自动生成密钥,

              然后生成的密钥名称由-keyout参数指定。当指定newkey选项时,后面指定rsa:bits说明产生

              rsa密钥,位数由bits指定。 如果没有指定选项-key和-newkey,默认自动生成秘钥。

     -out    :-out 指定生成的证书请求或者自签名证书名称

     -config :默认参数在ubuntu上为 /etc/ssl/openssl.cnf, 可以使用-config指定特殊路径的配置文件

     -nodes  :如果指定-newkey自动生成秘钥,那么-nodes选项说明生成的秘钥不需要加密,即不需要输入passphase.  

     -batch  :指定非交互模式,直接读取config文件配置参数,或者使用默认参数值     

openssl ca 命令 签署证书

openssl ca -in httpd.csr -out /etc/pki/CA/certs/httpd.crt -days 730

ca命令也是用于签署证书的,所以它所需要的文件除了配置文件外就是私钥文件和证书请求文件,而签名后生成的文件是证书文件,因此使用"-in"指定的对象是待签署文件"-infiles"则是指定多个待签署文件,"-keyfile"是指定私钥文件,"-out"是指定输出的证书文件

 进行自签名,如果证书请求文件的信息与签名用的CA证书的信息不一致就会出现类似如下的错误提示。

相关推荐

  1. openssl相关命令

    2024-01-04 15:00:04       11 阅读
  2. openssl+EVP详解

    2024-01-04 15:00:04       28 阅读
  3. opensslopenssl.cnf配置文件详解

    2024-01-04 15:00:04       26 阅读
  4. openssl的x509命令工具

    2024-01-04 15:00:04       41 阅读
  5. openssl 常用命令 pkcs12

    2024-01-04 15:00:04       45 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-01-04 15:00:04       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-01-04 15:00:04       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-01-04 15:00:04       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-01-04 15:00:04       20 阅读

热门阅读

  1. word press 好用的插件

    2024-01-04 15:00:04       41 阅读
  2. AI:107-基于深度学习的图像识别—详细讲解

    2024-01-04 15:00:04       42 阅读
  3. 系统运维-Apache服务的基础安装与使用

    2024-01-04 15:00:04       39 阅读
  4. 深度学习中的泛化能力是什么意思。

    2024-01-04 15:00:04       47 阅读
  5. 【WPF.NET开发】WPF中的命令

    2024-01-04 15:00:04       37 阅读
  6. 几种Go语言开发的IDE

    2024-01-04 15:00:04       30 阅读
  7. Moonsong Labs与Web3演变

    2024-01-04 15:00:04       30 阅读
  8. 机器视觉系统选型-选型-总结

    2024-01-04 15:00:04       37 阅读