Warning: stream_socket_enable_crypto(): SSL operation failed with code 1 Warning: stream_socket_enable_crypto(): SSL operation failed with code 1 apache apache

Warning: stream_socket_enable_crypto(): SSL operation failed with code 1


This is due to the new verify-by-default policy in PHP 5.6. It's not set in php.ini; it's an option you an provide to fopen wrappers or stream contexts. Have a look at the options here, especially verify_peer. PHPMailer allows you to set these params during the smtpConnect() method, but there is no option to pass options into the smtpSend() method, so you will need to subclass PHPMailer to get at that.

You may find the alternative simpler - don't try to use a self-signed or unverifiable certificate.


There is a lot of configs that makes this error come up, but more often it is that your system's configuration is not set up properly. To do it correctly, follow this:

  1. Check if you have cacert.pem file for OPENSSL or not. If you don't, download proper version from of cacert.pem according to your php version and config your php.ini file as "2"

  2. If you have this file then you have to lookup inside of your php.ini file and see if it has been set in it or not. To do so: lookup for line:

    openssl.cafile ="example address..\cacert.pem"

If you find the line with an specific address, look for cacert.pem file in that address, if you find it, than it is all done with cacert.pem file. Else, you should use the correct address.


in laRAVEL 5.4 ERROR

C:\xampp\htdocs\itis_db\vendor\swiftmailer\swiftmailer\lib\classes\Swift\Transport\StreamBuffer.php

and find out this function inside StreamBuffer.php

private function _establishSocketConnection()

and paste this two lines inside of this function

$options['ssl']['verify_peer'] = FALSE;$options['ssl']['verify_peer_name'] = FALSE;

and reload your browser and try to run your project again. For me I put on like this:

private function _establishSocketConnection(){    $host = $this->_params['host'];    if (!empty($this->_params['protocol'])) {        $host = $this->_params['protocol'].'://'.$host;    }    $timeout = 15;    if (!empty($this->_params['timeout'])) {        $timeout = $this->_params['timeout'];    }    $options = array();    if (!empty($this->_params['sourceIp'])) {        $options['socket']['bindto'] = $this->_params['sourceIp'].':0';    }   $options['ssl']['verify_peer'] = FALSE;    $options['ssl']['verify_peer_name'] = FALSE;    $this->_stream = @stream_socket_client($host.':'.$this->_params['port'], $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, stream_context_create($options));    if (false === $this->_stream) {        throw new Swift_TransportException(            'Connection could not be established with host '.$this->_params['host'].            ' ['.$errstr.' #'.$errno.']'            );    }    if (!empty($this->_params['blocking'])) {        stream_set_blocking($this->_stream, 1);    } else {        stream_set_blocking($this->_stream, 0);    }    stream_set_timeout($this->_stream, $timeout);    $this->_in = &$this->_stream;    $this->_out = &$this->_stream;}

Hope you will solve this problem.....