验证return:1在openssl输出中的含义


10

我不明白openssl的输出。运行openssl,如下所示:

#openssl s_client -connect google.com:443 -CAfile cacert.pem < /dev/null

最终一切都很好,因为最终实体的证书已经过验证,可以: Verify return code: 0 (ok)

但是return:1在下面的中间输出的开头加w / verify 呢?这是什么意思呢?

depth = 3 C =美国,O = Equifax,OU = Equifax安全证书颁发机构验证回报:1
depth = 2 C = US,O = GeoTrust Inc.,CN = GeoTrust Global CA验证回报:1
depth = 1 C =美国,O = Google Inc,CN = Google Internet Authority G2验证返回:1
depth = 0 C =美国,ST =加利福尼亚,L =山景城,O = Google Inc,CN = google.com验证返回:1

---
证书链
 0 s:/ C = US / ST = California / L = Mountain View / O = Google Inc / CN = google.com
   i:/ C = US / O = Google Inc / CN = Google Internet Authority G2
 1 s:/ C = US / O = Google Inc / CN = Google Internet Authority G2
   i:/ C = US / O = GeoTrust Inc./CN=GeoTrust全球CA
 2秒:/ C = US / O = GeoTrust Inc./CN=GeoTrust全球CA
   i:/ C = US / O = Equifax / OU = Equifax安全证书颁发机构
---


Answers:


13

SSL会将一个字段传递给verify回调函数(用于对证书的适用性进行最终验证),该字段称为preverify_okay字段,该字段指示证书链是否通过了适用于所有情况的基本检查。甲1意味着这些检查通过。

int verify_callback(int preverify_ok, X509_STORE_CTX *x509_ctx)

设置SSL_VERIFY_PEER标志时,verify_callback函数用于控制行为。它必须由应用程序提供并接收两个参数:preverify_ok指示是否通过了有关证书的验证(preverify_ok = 1)(preverify_ok = 0)。

这就是所verify return:1显示的。

如果需要更多详细信息,可以检查代码:

int MS_CALLBACK verify_callback(int ok, X509_STORE_CTX *ctx)
    {
    [ snip ]
    BIO_printf(bio_err,"verify return:%d\n",ok);
    return(ok);
    }

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.