OpenSSL 內建 Linux, Mac 等系統中,可以使用一些指令協助我們
openssl version -a
openssl help
openssl dgst -h
openssl ciphers -v
openssl speed
openssl s_time -connect remote.host:443 -www /test.html -new
openssl req \
-x509 -nodes -days 365 -sha256 \
-newkey rsa:2048 -keyout mycert.pem -out mycert.pem
echo -n | openssl s_client -connect $HOST:$PORTNUMBER -servername $SERVERNAME \
| openssl x509 > /tmp/$SERVERNAME.cert
https://serverfault.com/a/192731
# MD5 digest
openssl dgst -md5 filename
# SHA1 digest
openssl dgst -sha1 filename
# SHA256 digest
openssl dgst -sha256 filename
# 把 file.txt 轉 base64 後寫入到 terminal
openssl enc -base64 -in file.txt
# 寫入到 file.txt.enc
openssl enc -base64 -in file.txt -out file.txt.enc
# 直接在 terminal 輸出
$ echo "encode me" | openssl enc -base64
輸入後會要你打上密碼
openssl enc -aes-256-cbc -salt -in test.txt -out file.enc
解密
openssl enc -d -aes-256-cbc -in file.enc
除了 AES 外可用以下指令查詢所有可用的加密算法
openssl list-cipher-commands
先產生 2040 bits 的私鑰
openssl genrsa -out mykey.pem 2048
從私鑰再產生公鑰
openssl rsa -in mykey.pem -pubout
https://www.openssl.org/docs/manmaster/man1/
https://www.madboa.com/geek/openssl/
https://www.digicert.com/kb/ssl-support/openssl-quick-reference-guide.htm