在Ruby中关闭SSL证书验证

时间:2022-11-13 00:15:11

When using 'net/https' and ssl, how do I disable verification of the resulting SSL certificate?

使用'net / https'和ssl时,如何禁用对生成的SSL证书的验证?

1 个解决方案

#1


18  

The following code will disable verification of the certificate. Note that this necessarily implies that invalid certificates will be accepted.

以下代码将禁用证书的验证。请注意,这必然意味着将接受无效证书。

http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl?

#1


18  

The following code will disable verification of the certificate. Note that this necessarily implies that invalid certificates will be accepted.

以下代码将禁用证书的验证。请注意,这必然意味着将接受无效证书。

http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl?