Ssl

讓我們加密證書失敗“openssl verify”驗證

  • September 2, 2022

在建構我的openssl verify命令來驗證我的 Let’s Encrypt 證書時,我遵循了其他 Stack 答案的指導 - 有大量與此相關的內容,如下所示:

openssl verify -show_chain /etc/letsencrypt/live/mail.example.com/chain.pem /etc/letsencrypt/live/mail.example.com/cert.pem 

但它失敗並出現錯誤:

CN = mail.example.com
error 20 at 0 depth lookup: unable to get local issuer certificate
error /etc/letsencrypt/live/mail.example.com/cert.pem: verification failed
/etc/letsencrypt/live/mail.example.com/chain.pem: OK
Chain:
depth=0: C = US, O = Let's Encrypt, CN = R3 (untrusted)
depth=1: C = US, O = Internet Security Research Group, CN = ISRG Root X1

即使我代替fullchain.pemchain.pem仍然失敗。但這些都是 Let’s Encrypt 分發給我的所有證書!

我在這裡想念什麼?

openssl verify -show_chain /etc/letsencrypt/live/mail.example.com/chain.pem /etc/letsencrypt/live/mail.example.com/cert.pem 

這個命令是錯誤的。它將嘗試相互獨立地驗證所有給定的證書,即不建立信任鏈並驗證第一個。相反,命令應該是:

openssl verify -untrusted chain.pem cert.pem

-untrusted頒發中級證書。根證書 ISRG X1 將從現代系統的信任庫中獲取,否則應使用-trustedor給出-CAfile

引用自:https://unix.stackexchange.com/questions/715787