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 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() {


        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!
Go Back to List Page

Leave a comment

Name : Comment : view emoticons
Please consider signing up for our website.
If you sign up and log in:
  •   You can avoid the "I'm not a robot" captcha when commenting
  •   You can also avoid typing your name every time
  •   You can upload a picture for each comment
  •   You can change or delete your comment within 1 hour
  •   You can track all the comments you posted on this site
  •   You can read blog posts that are only open to members
  •   You can look up blogs using the search feature
  •   More privileges for our friends & families coming...

OK, Sign me up!

Emoticons are a great way to visually express how you feel.
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.