Using WordPress ‘https_ssl_verify’ PHP filter

The https_ssl_verify WordPress PHP Filter allows you to control SSL verification for non-local requests.

Usage

add_filter('https_ssl_verify', 'my_custom_https_ssl_verify', 10, 2);

function my_custom_https_ssl_verify($ssl_verify, $url) {
    // your custom code here
    return $ssl_verify;
}

Parameters

  • $ssl_verify (bool|string): Boolean to control whether to verify the SSL connection or path to an SSL certificate.
  • $url (string): The request URL.

More information

See WordPress Developer Resources: https_ssl_verify

Examples

Disable SSL verification for a specific domain

This code disables SSL verification for requests made to example.com.

add_filter('https_ssl_verify', 'disable_ssl_verification_for_example', 10, 2);

function disable_ssl_verification_for_example($ssl_verify, $url) {
    if (strpos($url, 'example.com') !== false) {
        return false;
    }
    return $ssl_verify;
}

Enable SSL verification for all requests

This code forces SSL verification for all requests.

add_filter('https_ssl_verify', 'enable_ssl_verification_for_all', 10, 2);

function enable_ssl_verification_for_all($ssl_verify, $url) {
    return true;
}

Disable SSL verification for all requests

This code disables SSL verification for all requests.

add_filter('https_ssl_verify', 'disable_ssl_verification_for_all', 10, 2);

function disable_ssl_verification_for_all($ssl_verify, $url) {
    return false;
}

Use a custom SSL certificate for a specific domain

This code uses a custom SSL certificate for requests made to example.com.

add_filter('https_ssl_verify', 'custom_ssl_certificate_for_example', 10, 2);

function custom_ssl_certificate_for_example($ssl_verify, $url) {
    if (strpos($url, 'example.com') !== false) {
        return '/path/to/your/certificate.pem';
    }
    return $ssl_verify;
}

Use a custom SSL certificate for all requests

This code uses a custom SSL certificate for all requests.

add_filter('https_ssl_verify', 'custom_ssl_certificate_for_all', 10, 2);

function custom_ssl_certificate_for_all($ssl_verify, $url) {
    return '/path/to/your/certificate.pem';
}