https_ssl_verify
云策文档标注
概述
https_ssl_verify 是一个 WordPress 过滤器,用于控制非本地请求的 SSL 验证行为。它允许开发者修改 SSL 验证设置,常用于调试或处理 SSL 证书问题。
关键要点
- 过滤器名称:https_ssl_verify
- 参数:$ssl_verify(布尔值或字符串,控制 SSL 验证或指定 SSL 证书路径),$url(字符串,请求 URL)
- 用途:在 WP_Http_Curl::request()、WP_Http_Streams::request() 和 WP_Http::request() 中应用,影响 HTTP 请求的 SSL 验证
- 版本历史:从 2.8.0 引入,5.1.0 添加 $url 参数
代码示例
add_filter( 'https_ssl_verify', '__return_false' );注意事项
禁用 SSL 验证(如使用 __return_false)可以绕过“cURL error 60”等问题,但出于安全考虑,强烈不建议在生产环境中使用。
原文内容
Filters whether SSL should be verified for non-local requests.
Parameters
$ssl_verifybool|string-
Boolean to control whether to verify the SSL connection or path to an SSL certificate.
$urlstring-
The request URL.
Source
$options['verify'] = apply_filters( 'https_ssl_verify', $options['verify'], $url );
Skip to note 2 content
Code Muffin
Disabling the SSL verification is a common way to get around the “cURL error 60” issue with wp_remote_get:
add_filter( 'https_ssl_verify', '__return_false' );Note that this is strongly recommended against for security reasons.