After December 3, i cant send Emails whit smtp from php (Codeigniter), i have not changed anything, I do not know what is happening.
Does anyone know if there is any update that left some function obsolete in some version of PHP?
Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
Filename: libraries/Email.php
Thanks for help!
I already solve this problem.
I realized that there is a lot of disinformation on the internet about this topic.
I hope this can be useful!
If you running PHP 5.3.7 or later.
Generate an vbs file from this file.
https://raw.githubusercontent.com/bagder/curl/master/lib/mk-ca-bundle.vbs
Open a Command Prompt as Administrator and run
C:>mk-ca-bundle.vbs
After finish that process you need to modify the php.ini.
openssl.cafile=C:\ca-bundle.crt
Restart the IIS web site and its all
Related
Enabled app insights on php project, it is working on host machine. However, during running the same code on local box getting following error: [seems some IIS config issue or update not sure]
Fatal error: Uncaught GuzzleHttp\Exception\RequestException: cURL error 0: The cURL request was retried 3 times and did not succeed. The most likely reason for the failure is that cURL was unable to rewind the body of the request and subsequent retries resulted in the same error. Turn on the debug option to see what went wrong. See https://bugs.php.net/bug.php?id=47204 for more information. (see http://curl.haxx.se/libcurl/c/libcurl-errors.html) in ....\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 186
and
Warning: curl_setopt_array(): Unable to create temporary file. in ....\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 56
Trace:
trace while running an application from IIS
check the plugins and look through the debug.log file in wp-content and most likely it is a plugin that is causing this issue. I found that Mailjet causes this issue when unconfigured. Simply activate the plugins found in the error log and this will help solve it. The Microsoft version of cURL in PHP will throw the error and the Linux variant will not.
I have a WordPress plugin that I created and it has stopped working because of a certificate error.
file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in
I contacted the inmotionhosting and they said the certificate was fine. The code in question is this:
$op = file_get_contents(plugins_url( '../PRTHSEL_Visualizer.html' , __FILE__ ));
It was suggested that I use an https request to get the file. I have searched but cannot find and answer on how to get a file contents within a WordPress plugin via https.
The problem was the file_get_contents() was given a url for a local file. Byt changing the path to a local it now works under PHP7. PHP 5 never verified the SSL by default but PHP7 does.
I can't get a xml file to load.
This code works great:
$url = 'http://www.w3schools.com/xml/note.xml';
$xml = simplexml_load_file($url);
print_r($xml);
But this one
$url = 'https://www.boardgamegeek.com/xmlapi2/thing?id=105551';
$xml = simplexml_load_file($url);
print_r($xml);
doesn't work. I get this error:
Warning: simplexml_load_file(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /storage/content/59/113059/boardgamelevelup.com/public_html/index.php on line 19 Warning: simplexml_load_file(): Failed to enable crypto in /storage/content/59/113059/boardgamelevelup.com/public_html/index.php on line 19 Warning: simplexml_load_file(https://www.boardgamegeek.com/xmlapi2/thing?id=105551): failed to open stream: operation failed in /storage/content/59/113059/boardgamelevelup.com/public_html/index.php on line 19 Warning: simplexml_load_file(): I/O warning : failed to load external entity "https://www.boardgamegeek.com/xmlapi2/thing?id=105551" in /storage/content/59/113059/boardgamelevelup.com/public_html/index.php on line 19
The xml file from boardgamegeek works on other sites. Should I use a different php code to load that xml file?
short cookbook answer:
Download https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt and place that file on your server.
Add
$context = stream_context_create(array('ssl'=>array(
'verify_peer' => true,
'cafile' => '/path/to/ca-bundle.crt'
)));
libxml_set_streams_context($context);
to your script so it gets executed before simplexml_load_file().
Or - instead of the code above - set openssl.cafile=/path/to/ca-bundle.crt in your php.ini.
Very short explaination:
Your php version uses openssl to handle the https transport. openssl tries to verify whether the server really is who it claims to be. It does that by checking whether its certificate is trusted. A X.509 certificate contains some data about the owner and is signed by an issuer (itself having a certificate that is again signed and so on and on until a certificate where owner and issuer are identical -> self-signed/root certificate). A certificate is considered "trusted" if in that chain of certificates there is (at least) one certificate on which openssl "says": "ok, I have been instructed to trust this one". This instruction takes the form of (or can take the form of) "here's a file containing certificates that you're supposed to trust" (cafile).
The above code tells the libxml-wrapper of php to tell openssl where that cafile is when simplexml_load_file uses the https/openssl-wrapper.
And openssl.cafile=/path/to/ca-bundle.crt just sets it as default; unless instructed otherwise all openssl operations will use that file - including libxml/simple_xml_loadfile.
The ca-bundle.crt I've linked to is from a project that "claims" to provide the extracted root certificates as shipped with mozilla firefox. Regarding "claims": I have no reason to doubt that this really is the untampered root cert list; but you never know: You're putting your trust a) in this project and b) mozilla doing a good job and only putting trustworthy certificates in that list....
for more explaination see http://phpsecurity.readthedocs.org/en/latest/Transport-Layer-Security-%28HTTPS-SSL-and-TLS%29.html#php-streams
The work and example that #VolkerK displayed was excellent and simple.
While this method didn't work for me, I took it one step further and basically removed the security for the moment.
$context = stream_context_create(array('ssl'=>array(
'verify_peer' => false,
"verify_peer_name"=>false
)));
libxml_set_streams_context($context);
$sxml = simplexml_load_file($webhostedXMLfile);
Yes, this is bad practice, but sometimes you need a temp fix instead of messages like this:
Warning: simplexml_load_file(): SSL operation failed with code 1.
OpenSSL Error messages: error:14090086:SSL
routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in
/srv/www/resources/public_html/files/etc/file.php on line 150 Warning:
simplexml_load_file(): Failed to enable crypto in
/srv/www/resources/public_html/files/etc/file.php on line 150
I hope it helps someone else.
I'm running Moodle on PHP 5.5.7 64bit nts on Windows Server 2008 R2 with MySQL 5.5.36.
Up until two days ago, there were no problems. To deal with Xdebugger being such a memory hog, an extra CPU and more memory was assigned to the virtual machine. The Windows license was also activated. The entire vm was rebooted. (I had restarted the machine before prior to this, with no problems).
I am now receiving the following warning when I access any page on the site:
PHP Warning: mysqli::mysqli(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
in C:\inetpub\wwwroot\moodle\lib\dml\mysqli_native_moodle_database.php on line 375
I created a test php page that simply consists of the following:
$mysqli = new mysqli("127.0.0.1", "moodleuser", 'xxxx', "moodle", 3306);
if ($result = $mysqli->query("SELECT * from mdl_user limit 10")) {
echo "Select returned $result->num_rows";
} else {
echo "Error";
}
$mysqli->close();
I receive the following output:
PHP Warning: mysqli::mysqli(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.in C:\inetpub\wwwroot\moodle\info.php on line 17
PHP Warning: mysqli::query(): Couldn't fetch mysqli in C:\inetpub\wwwroot\moodle\info.php on line 18
PHP Warning: mysqli::close(): Couldn't fetch mysqli in C:\inetpub\wwwroot\moodle\info.php on line 24
I have checked that "127.0.0.1 localhost" exists in my hosts file and that the IPv6 "::1" line has been commented out.
I have also attempted to use "localhost" but same problem.
The bizarre thing is that if I refresh the page, occasionally, and completely at random, the warning doesn't occur and the correct output is given.
I have attempted to disable the warnings, but php appears to be ignoring me. Also, disabling the warning is not exactly ideal.
Any ideas?
EDIT:
So after much pain staking back and forths between PHP and MySQL and IIS, it looks like (once again) it was php.ini to blame.
To be honest, I cant even tell you which setting was the problem - but I changed all possible timeout related settings in php.ini to a large number (10000 or -1 depending on the setting), as well as the connection_timeout for mysql in my.ini.
I am still yet to figure out which one was causing the problem, but will edit this post if I ever do.
So after much pain staking back and forths between PHP and MySQL and IIS, it looks like (once again) it was php.ini to blame.
To be honest, I cant even tell you which setting was the problem - but I changed all possible timeout related settings in php.ini to a large number (10000 or -1 depending on the setting), as well as the connection_timeout for mysql in my.ini.
I am still yet to figure out which one was causing the problem, but will edit this post if I ever do.
I have been working on my first PHP contact form.
I have also been running into some problems. I have gotten the files to all talk to each other, and it has gotten to the point where it looks like it is going to work. But, after you input the information in the form, press send, it comes back with this error:
Deprecated: Function eregi() is deprecated in /home/content/12/11666412/html/phpMailer/class.phpmailer.php on line 594
Warning: fsockopen() [function.fsockopen]: unable to connect to smtp.gmail.com:587 (Connection refused) in /home/content/12/11666412/html/phpMailer/class.smtp.php on line 122
Thank you!
So, I assume 2 things:
1: I should try using a different port # for connecting to google (587 has worked for me in the past on a different server, is this something that sometimes changes?). What port number should I be using?
2: Something is wrong in the PHP mailer files (that I downloaded from the PHPmailer site). Should I try redownloading them? I doubt anything is wrong with the PHPmailer, seems to be a very reputable tool that people use, the code is too advanced for me to analyze.
Any help would be appreciated.