root@PLAY ~]# mkdir -p /root/.certs/ ####建立目錄,用來存放證書
[root@PLAY ~]# echo -n | openssl s_client -connect smtp.163.com:465 | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > ~/.certs/163.crt ####向163請求證書
depth=2 C = US, O = GeoTrust Inc., CN = GeoTrust Global CA
verify return:1
depth=1 C = US, O = GeoTrust Inc., CN = GeoTrust SSL CA - G3
verify return:1
depth=0 C = CN, ST = Zhejiang, L = Hangzhou, O = "NetEase (Hangzhou) Network Co., Ltd", OU = MAIL Dept., CN = *.163.com
verify return:1
DONE
[root@PLAY ~]# certutil -A -n "GeoTrust SSL CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt ####添加一個證書到證書數據庫中
[root@PLAY ~]# certutil -A -n "GeoTrust Global CA" -t "C,," -d ~/.certs -i ~/.certs/163.crt ####添加一個證書到證書數據庫中
[root@PLAY ~]# certutil -L -d /root/.certs ####列出目錄下證書
Certificate Nickname Trust Attributes
SSL,S/MIME,JAR/XPI
GeoTrust SSL CA 數據庫
而後前往163郵箱打開smtp並獲取客戶端受權碼測試
set from=17737156701@163.com
set smtp=smtps://smtp.163.com:465
set smtp-auth-user=17737156701@163.com
set smtp-auth-password=*********
set smtp-auth=login
set ssl-verify=ignore
set nss-config-dir=/root/.certs加密
看起來已經成功了,可是發送完郵件還有報錯:證書不被信任,且命令行就此卡住,須要按鍵才能出現命令提示符spa
Error in certificate: Peer's certificate issuer is not recognized.命令行
[root@PLAY ~]# cd /root/.certs/
[root@PLAY .certs]# ll
total 80
-rw-r--r-- 1 root root 1793 Jul 6 14:36 163.crt
-rw------- 1 root root 65536 Jul 6 14:37 cert8.db
-rw------- 1 root root 16384 Jul 6 14:37 key3.db
-rw------- 1 root root 16384 Jul 6 14:37 secmod.db
[root@PLAY .certs]# certutil -A -n "GeoTrust SSL CA - G3" -t "Pu,Pu,Pu" -d ./ -i 163.crt
Notice: Trust flag u is set automatically if the private key is present.blog