OpenSSL相关命令(for Linux)详细介绍

豆豆网   技术应用频道   2007年07月10日  【字号: 收藏本文

内容摘要:OpenSSL相关命令(for Linux)详细介绍

  加密算法:

  对称加密算法:

  DES、IDEA、RC2、RC4、AES、Skipjack ......

  非对称加密算法:

  RSA、DSA、DiffieHellman、PKCS、PGP ......

  单向的HASH算法属于报文摘要算法,虽然有些也出自OpenSSL库。

  命令操作:

  1、生成普通私钥:

  [weigw@TEST src]$ openssl genrsa -out privatekey.key 1024
  Generating RSA private key, 1024 bit long modulus ....++++++ .......++++++ e is 65537 (0x10001)

  2、生成带加密口令的密钥:

  [weigw@TEST src]$ openssl genrsa -des3 -out privatekey.key 1024
  Generating RSA private key, 1024 bit long modulus ............++++++ .....................++++++ e is 65537 (0x10001) Enter pass phrase for privatekey.key: Verifying - Enter pass phrase for privatekey.key:
  

  在生成带加密口令的密钥时需要自己去输入密码。对于为密钥加密现在提供了一下几种算法:

  -des encrypt the generated key with DES in cbc mode
  -des3 encrypt the generated key with DES in ede cbc mode (168 bit key)
  -aes128, -aes192, -aes256 encrypt PEM output with cbc aes

  去除密钥的口令:

  [weigw@TEST src]$ openssl rsa -in privatekey.key -out
  privatekey.key Enter pass phrase for privatekey.key: writing RSA key
 

  通过生成的私钥去生成证书:

  [weigw@TEST src]$ openssl req -new -x509 -key privatekey.key -out cacert.crt -days 1095
  You are about to be asked to enter information that will be incorporated into your certificate request.
  What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank.
  -----
  Country Name (2 letter code) [GB]:CN
  State or Province Name (full name) [Berkshire]:beijing
  Locality Name (eg, city) [Newbury]:beijing
  Organization Name (eg, company) [My Company Ltd]:wondersoft
  Organizational Unit Name (eg, section) []:develop
  Common Name (eg, your name or your server's hostname) []:WeiGW
  Email Address []:weigongwan@sina.com
  在生成证书的时候需要按照提示输入一些个人信息。

责编:豆豆技术应用

正在加载评论...