Using WordPress ‘https_local_ssl_verify’ PHP filter

The https_local_ssl_verify WordPress PHP Filter allows you to control SSL verification for local HTTP API requests.

Usage

add_filter('https_local_ssl_verify', 'my_custom_ssl_verify', 10, 2);

function my_custom_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_local_ssl_verify

Examples

Disable SSL verification

Disable SSL verification for all local HTTP API requests.

add_filter('https_local_ssl_verify', '__return_false');

Enable SSL verification

Enable SSL verification for all local HTTP API requests.

add_filter('https_local_ssl_verify', '__return_true');

Disable SSL verification for specific domain

Disable SSL verification for local HTTP API requests to a specific domain.

add_filter('https_local_ssl_verify', 'disable_ssl_for_specific_domain', 10, 2);

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

Enable SSL verification for specific domain

Enable SSL verification for local HTTP API requests to a specific domain.

add_filter('https_local_ssl_verify', 'enable_ssl_for_specific_domain', 10, 2);

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

Use custom SSL certificate

Use a custom SSL certificate for local HTTP API requests.

add_filter('https_local_ssl_verify', 'use_custom_ssl_certificate', 10, 2);

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