Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Bypass the SSL check during updates as WordPress MU-Plugin.
<?php
/**
* Plugin Name: Upgrade SSL Bypass
* Description: The DB-Upgrade process for networks does not work if there's an error with your SSL certificate. This plugin bypasses the check by disabling the verification in case of an error.
* Version: 2013-01-02.1502
* Author: Franz Josef Kaiser <wecodemore@gmail.com>
* Author URI: http://unserkaiser.com
* License: The MIT License (MIT)
* LicenseURI: http://www.opensource.org/licenses/mit-license.php
*/
// No direct file access
defined( 'ABSPATH' ) OR exit;
add_filter( 'http_request_args', 'upgrade_ssl_bypass', 10, 2 );
/**
* Callback for a HTTP request used to switch the
* SSL verification in case of a WP error response.
* @param array $r Request arguments
* @param string $url Request URL
* @return array $r
*/
function upgrade_ssl_bypass( $r, $url )
{
if (
! isset( $_GET )
OR ! isset( $_GET['action'] )
OR 'upgrade' !== $_GET['action']
)
return $r;
if (
is_wp_error( $response = wp_remote_get(
admin_url( 'upgrade.php?step=upgrade_db' )
,array(
'timeout' => 120
,'httpversion' => '1.1'
)
) )
AND strstr( $response->get_error_message(), 'SSL: certificate subject name' )
)
{
remove_filter( current_filter(), __FUNCTION__ );
add_filter( 'https_ssl_verify', '__return_false' );
}
return $r;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment