1

在 OpenSSL 中,我可以使用以下命令验证证书。

$ openssl verify -CApath /etc/ssl/certs cert_to_be_verified.pem

我想知道 GnuTLS 中是否有类似的命令。我能找到的最接近的是“certtool”。但是“certtool”需要指定CA文件,这与OpenSSL相比有点不方便。非常感谢您的提示!

4

1 回答 1

2

实际上 certtool 不需要您指定 CA 文件。它将使用您系统的证书列表。

certtool 文档

可以使用 --load-ca-certificate 加载受信任的证书列表。如果没有提供证书列表,则使用系统的证书列表。请注意,在验证期间可能会探索多个路径。成功验证后,成功的路径将是最后一个。它可以与 --verify-purpose 或 --verify-hostname 结合使用。

$ certtool --verify --infile google.com.crt
Loaded system trust (168 CAs available)
Loaded 3 certificates, 168 CAs and 0 CRLs

    Subject: CN=GeoTrust Global CA,O=GeoTrust Inc.,C=US
    Issuer: OU=Equifax Secure Certificate Authority,O=Equifax,C=US
    Checked against: OU=Equifax Secure Certificate Authority,O=Equifax,C=US
    Output: Verified. The certificate is trusted.

    Subject: CN=Google Internet Authority G2,O=Google Inc,C=US
    Issuer: CN=GeoTrust Global CA,O=GeoTrust Inc.,C=US
    Checked against: CN=GeoTrust Global CA,O=GeoTrust Inc.,C=US
    Output: Verified. The certificate is trusted.

    Subject: CN=*.google.com,O=Google Inc,L=Mountain View,ST=California,C=US
    Issuer: CN=Google Internet Authority G2,O=Google Inc,C=US
    Checked against: CN=Google Internet Authority G2,O=Google Inc,C=US
    Output: Verified. The certificate is trusted.

Chain verification output: Verified. The certificate is trusted.
于 2017-09-29T09:25:53.150 回答