PHP 5.6 and SSL Operation Failed error
When I enabled SSL on my website, it broke two vendor libraries that I'm using from composer, which used to work without any problem prior to SSL certificate installation.
One is the outgoing emails using PHP SwiftMailer and the other is Googles reCAPTCHA service using marwelln's recaptcha composer package.
It turns out that starting PHP v5.6.0 release, it changed the default values for
Here's the solution to correct these two problems:
For SwiftMailer, disable the SSL check by modifying the
For marwelln's recaptcha, replace the
That should do it and make sure to test them out!
One is the outgoing emails using PHP SwiftMailer and the other is Googles reCAPTCHA service using marwelln's recaptcha composer package.
It turns out that starting PHP v5.6.0 release, it changed the default values for
verify_peer
and verify_peer_name
to TRUE, which broke the two operation code mentioned above.Here's the solution to correct these two problems:
For SwiftMailer, disable the SSL check by modifying the
_establishSocketConnection()
function in StreamBuffer.php
by adding the following two lines before stream_context_create command:
// two new lines to be added
$options['ssl']['verify_peer'] = FALSE;
$options['ssl']['verify_peer_name'] = FALSE;
// existing code in _establishSocketConnection() function
$streamContext = stream_context_create($options);
For marwelln's recaptcha, replace the
simple()
function in Marwelln\Recaptcha\Request.php
as follows:
protected function simple() {
$arrContextOptions=array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false,
),
);
return json_decode(file_get_contents($this->url, false, stream_context_create($arrContextOptions)));
// below is the original code that has been replaced
//return json_decode(file_get_contents($this->url));
}
That should do it and make sure to test them out!
Leave a comment
If you sign up and log in:
OK, Sign me up!
However, there are times when unintended content is converted to emoticon because the content happens to have one of the emoticon symbols. That's why it's always good idea to preview your comment before posting and when you see this type of problem, you can indicate NOT to auto convert.