function request_firewall_update($external_services = false)
{
$args = array('timeout' => $this->get_option('timeout'), 'sslverify' => true);
$hostname = $this->get_option('hostname');
$path = $external_services ? 'service-ips-external' : 'service-ips';
$data = false;
$https_error = null;
$retry = 2;
$protocol = 'https';
do {
$retry--;
$args['sslverify'] = 'https' == $protocol ? true : false;
$r = wp_remote_get($url = sprintf("%s://%s/%s?cidr_ranges=1", $protocol, $hostname, $path), $args);
if (200 == wp_remote_retrieve_response_code($r)) {
if (99 == $this->get_option('connection_error_code')) {
$this->clear_connection();
}
$data = @unserialize(wp_remote_retrieve_body($r));
break;
}
if ('https' == $protocol) {
$https_error = $r;
$protocol = 'http';
}
usleep(100);
} while ($retry > 0);
if ($https_error != null && !empty($data)) {
$r_code = wp_remote_retrieve_response_code($https_error);
if (200 != $r_code) {
$error_message = sprintf('Unexpected HTTP response code %s', $r_code);
if (false === $r_code) {
$error_message = 'Unable to find an HTTP transport that supports SSL verification';
} elseif (is_wp_error($https_error)) {
$error_message = $https_error->get_error_message();
}
$this->update_option('connection', time());
$this->update_option('connection_error_code', 99);
$this->update_option('connection_error_message', sprintf(__('Warning: The VaultPress plugin is using an insecure protocol because it cannot verify the identity of the VaultPress server. Please contact your hosting provider, and ask them to check that SSL certificate verification is correctly configured on this server. The request failed with the following error: "%s". If you’re still having issues please <a href="%1$s">contact the VaultPress Safekeepers</a>.', 'vaultpress'), esc_html($error_message), 'http://vaultpress.com/contact/'));
}
}
return $data;
}