openssl 指令
作者: cross 日期: 2006-11-05 20:12
產生 private key 私密金鑰 及 憑證 cert (365 天, 1024 bits)
openssl req -new -x509 -keyout server.key -out server.crt -days 3650 -newkey rsa:1024
-nodes : 可以不加密碼
-subj '/C=TW/ST=Taiwan/L=Taipei/CN=ssorc.tw/emailAddress=cross@ssorc.tw' : 個人資訊,加的話不會出用提示的方式
產生私密金鑰(private key) & 憑證要求(certificate signing request = csr)
openssl req -new -keyout server.key -out server.csr -days 365 -newkey rsa:1024
如果要引用已有 private key 了來產生憑證要求
openssl req -new -key server.key -out server.csr
簽署 csr 產生 crt
openssl x509 -in server.csr -out server.crt -req -text -signkey server.key
CA 簽發
openssl ca -policy policy_anything -out server.crt -infiles server.csr
檢查簽署
openssl req -in server.csr -noout -verify -key server.key
檢查憑證
openssl verify server.crt
查看 csr 內容
openssl req -in server.csr -noout -text
-noout : 不輸出BEGIN CERTIFICATE REQUEST
查看 csr 內容並檢查
openssl req -in server.csr -noout -text -verify
查看 crt 內容
openssl x509 -in server.crt -text
其它查看的參數
-issuer
-subject
-dates
產生 Windows用的 p12
openssl pkcs12 -export -in server.crt -inkey server.key -out windows.p12
如果反過來的話
openssl pkcs12 -in windows.p12 -out server.crt
windows DER
openssl x509 -in cacert.pem -out cacert.der -outform DER
產生 public key
openssl rsa -in server.key -pubout
產生 rsa key
openssl genrsa
openssl genrsa 1024
openssl genrsa 1024 -out server.rsa.key
文件加密、解密
明文文件(plain text) :test.txt
密文文件(cipher text):test.msg
文件加密
echo "this is a test file" > test.txt
openssl smime -encrypt -in test.txt -out test.msg cert.pem
文件解密
openssl smime -decrypt -in test.msg -recip cert.pem -inkey key.pem
驗證簽章(Verify Signature)
openssl smime -sign -inkey key.pem -signer cert.pem -in test.txt -out test.sig
openssl smime -verif -in test.sig -signer cert.pem -out test2.txt -CAfile cacert.pem
測試 TLS
openssl s_client -CAfile cacert.pem -connect localhost:993
openssl s_client -connect remote.host:25 -starttls smtp
openssl s_time -connect remote_host:443
Benchmark
openssl speed
openssl speed rsa
ref: http://www.madboa.com/geek/openssl/
ref: http://www.ascc.net/nl/91/1819/02.txt
ref: http://www.study-area.org/tips/certs/certs.html
上一篇
返回
下一篇
標籤:




如何檢查有沒有SSL renegotiation 功能 (2011-12-29 17:22)
SSL的弱點-SSL renegotiation (2011-11-02 09:31)
用 OpenVPN 2.2.0建構SSL VPN加密連線 (2011-07-04 15:01)
apache強制某路徑使用https方式連線 (2011-06-26 16:31)
openssl 指令 (續) windows 的 pfx、p12 篇 (2008-11-21 16:53)
apache + mod_gnutls 達到單一IP多個domain使用SSL服務 (2008-09-17 19:26)
apache+mod_ssl+openssl+php+mm+mysql重新編譯 (2007-05-04 13:52)
建置SSL憑證 - OpenSSL (2006-11-14 22:57)
Postfix + TLS (2006-11-14 21:36)