ykjsw.txt

July 28, 2009

openssl命令的用法

分类: linux — 标签:, — ykjsw @ 1:12 pm

密钥的生成

 a. 生成非对称密钥对
  openssl genrsa -out rsa.key
 b. 指定生成的密钥的位数,默认512
  openssl genrsa -out rsa_2048.key 2048
 c. 为私钥添加密码 (一般都不用)
  openssl genrsa -out rsa_des3.key -des3

 
 密钥的查看
 d. 查看私钥
  openssl rsa -in rsa.key
 e. 查看公钥
  openssl rsa -in rsa.key -pubout
 f. 查看公钥和modulus
  openssl rsa -in rsa.key -modulus
 g. 查看密钥的详细信息,包含component prime等细节信息,这些信息的值都是冒号分割的,称为abstract
  openssl rsa -in rsa.key -text
 h. 查看只有public key的文件
  openssl rsa -in pub.txt -pubin
  注:
   pub.txt 可由
   openssl rsa -in rsa.key -pubout >pub.txt
   或
   openssl rsa -in rsa.key -pubout -out pub.txt
   产生
   如果pub.txt 中不是公钥将报错, -pubin 仅仅说明 -in 所指定的文件里面是什么
 i. 只查看key的其他信息,不显示key
  openssl  rsa -in rsa.key -noout

 

 其它:
 
 检查是否含有某个子命令
  openssl no-rsa
  输出rsa,命令的返回值为1,说明存在该子命令
  openssl no-des5
  输出no-des5 命令的返回值为0,说明不存在des5这个子命令
 
 分析key的详细信息
  openssl asn1parse -in rsa.key
  openssl asn1parse -in pub.txt

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress 中文站