In PHP 5.6.x, all encrypted client streams has peer verification enabled by default. This will use OpenSSL’s default CA bundle to verify the peer certificate.
I worked with the Facebook API on a recent web application project and implemented Facebook social login to it.
In the implementation code, I used PHP copy()
function to download and move users Facebook profile picture to a given folder but I kept getting the following error.
Warning: copy(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /path-to-php-file.php on line
130
To fix this problem, all I did was simply to disable SSL verification like so:
$contextOptions = array(
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false,
),
);
// the copy or upload shebang
$copy = copy( $fb_avatar_url, $local_avatar_url, stream_context_create( $contextOptions ) );
Conclusion
I know disabling SSL verification isn’t the best thing to do but I was running out of time because we had to ship quickly.