Error getimagesize(): SSL operation failed with code 1 [duplicate] - php

This question already has answers here:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in file_get_contents
(1 answer)
file_get_contents(): SSL operation failed with code 1, Failed to enable crypto
(21 answers)
SSL routines:tls_process_server_certificate:certificate verify failed
(1 answer)
Closed 4 months ago.
This post was edited and submitted for review 4 months ago and failed to reopen the post:
Original close reason(s) were not resolved
I made XAMPP run locally with SSL and it was possible to access the site with HTTPS. However, when you try to use image-related functions, such as PHP's getimagesize(), it gives the error below:
Warning: getimagesize(): SSL operation failed with code 1. OpenSSL Error messages: error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in C:\xampp\htdocs\gebrascam\controllers\ajaxController.php on line 560
Warning: getimagesize(): Failed to enable crypto in C:\xampp\htdocs\gebrascam\controllers\ajaxController.php on line 560
I generated a local certificate and pointed to it on the server when I created the SSL.
Searching about the error, I thought I should change the path where openssl.cafile was pointed, but I made the change and it didn't solve.
Would you have any idea how to solve it or even find a way forward?

Related

How to configure openssl to work with file_get_contents

We run an apache2 server and want to use google recaptcha due to high volume of bots on our newsletter.
Therefore I implemented some lines of developers php-code which in general should work ... but not on my server.
I investigated further and found that the function file_get_contents() ends with an SSL error.
file_get_contents(self::SITE_VERIFY_URL, false, $context)
Below you can find an extract from the servers log file.
PHP Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:\nerror:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed in /var/www/html/app/lib/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php on line 68
PHP Warning: file_get_contents(): Failed to enable crypto in /var/www/html/app/lib/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php on line 68
PHP Warning: file_get_contents(https://www.google.com/recaptcha/api/siteverify): failed to open stream: operation failed in /var/www/html/app/lib/vendor/google/recaptcha/src/ReCaptcha/RequestMethod/Post.php on line 68
This brought me to the conclusion that Openssl is misconfigured.
So I:
reinstalled ca-certificates with apt-get purge ca-certificate
Also downloaded the cacert.pem and linked it in the php.ini
checked if curl works properly, but it doesnt (every call of curl ends with curl: (60) SSL certificate problem: unable to get local issuer certificate
checked openssl.cnf which looks ok to me.
Any ideas how to solve this would be great.
So I found the problem:
First I changed the filepath according to the comment by drew010.
Then I fixed issues on my server with file permissions of /etc/ssl/certs according to this post: https://askubuntu.com/a/636979
Now file_get_contents does not invoke any errors and recaptcha runs smoothly.

SSL Php 7 trouble

I change my server and now I have some problem with the function fsockopen() and file_get_contents()
I always has this error :
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /home/curl.php on line 6
I know I can tell by the code to not verify the peer and trust certificate, but I'm pretty sure I have a problem of configuration in my php. I have already configured the openssl.cafile in php.ini with the last pem
If any one has a solution and could help me, I'll appreciate it.
Thank you

SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol [duplicate]

This question already has answers here:
file_get_contents(): SSL operation failed with code 1, Failed to enable crypto
(21 answers)
How to set 'verify_peer_name=false' SSL context option via php.ini in PHP 5.6
(1 answer)
Closed 5 years ago.
file_get_contents(): SSL operation failed with code 1. And more
This answer is not working with me.I have already try it. I don't have "certificate verify failed" issue.
First all of I am new with server configuration.
My issue is when I am using local-machine in which OpenSSl and ssl certificate is not installed....then my code upload image successfully on Facebook Via using Facebook SDK for PHP.
But When I upload same code on Server where ssl enable and https working fine then my code showing me error :-
Warning: fopen(): SSL operation failed with code 1. OpenSSL Error messages:
error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol
at ErrorHandler ->handleError ('2', 'fopen(): SSL operation failed with code 1. OpenSSL Error messages: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol', '/facebook/php-sdk-v4/src/Facebook/FileUpload/FacebookFile.php', '91', array())
I don't know what's going wrong. Is it any server configuration issue or anything else ?
My machine PHP version is:- PHP 5.5.9-1ubuntu4.20 (cli)
My server PHP version is :- PHP 5.6.11-1ubuntu3.4 (cli)

file_get_contents() SSL error

I followed a certain tutorial found here to install Wordpress onto App Engine, using a SQL Cloud Database.
I'm up to the point when I have to run the setup script to download the Wordpress archive and plugins. When that command is ran I get the following errors:
Downloading the WordPress archive...
Warning: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /Users/Me/Sites/Blog/src/Project.php on line 47
Warning: file_get_contents(): Failed to enable crypto in /Users/Me/Sites/Blog/src/Project.php on line 47
Warning: file_get_contents(https://wordpress.org/latest.zip): failed to open stream: operation failed in /Users/Me/Sites/Blog/src/Project.php on line 47
I've looked at multiple resources to combat this issue such as, this one, where they suggest to set the verification to the peer to false, but I do not have that option within this project. I also found that someone suggested to use curl instead but I'm unsure how to use that without breaking the project.

Composer "Download failed" Error

i use xampp in Windows and my PHP Version is 5.5.15 .
need to install composer for Start work with laravel framework. but my problem is here, when i want install composer, be faced with this error :
Download failed: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
file_get_contents(): Failed to enable crypto
file_get_contents(https://getcomposer.org/composer.phar): failed to open stream: operation failed
Download failed: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
file_get_contents(): Failed to enable crypto
file_get_contents(https://getcomposer.org/composer.phar): failed to open stream: operation failed
Download failed: file_get_contents(): SSL operation failed with code 1. OpenSSL Error messages:
error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed
file_get_contents(): Failed to enable crypto
file_get_contents(https://getcomposer.org/composer.phar): failed to open stream: operation failed
The download failed repeatedly, aborting.
What should I do?
and is there a way to install laravel without using composer ?
You basically have to set the environment variable SSL_CERT_FILE to the path of the PEM file of the ssl-certificate downloaded from the following link : http://curl.haxx.se/ca/cacert.pem.
It took me a lot of time to figure this out.
For a detailed answer, you can have a look here: https://stackoverflow.com/questions/34590842/cannot-install-composer-on-mac-os-x
If you are using Kaspersky, try to disable the Encrypted connection scanning (or set the Scan encrypted connections upon request from protection components option) and try again.
If you have the Always scan encrypted connections you can get errors like these:
[Composer\Downloader\TransportException]
The "https://packagist.org/packages.json" file could not be downloaded: SSL operation failed with code 1. OpenSSL Error messages:
error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed
Failed to enable crypto
failed to open stream: operation failed
[RuntimeException]
Failed to clone https://github.com/doctrine/inflector.git via https, ssh protocols, aborting.
- https://github.com/doctrine/inflector.git
Cloning into 'C:\Users\User\my-project\vendor\doctrine\inflector'...
fatal: unable to access 'https://github.com/doctrine/inflector.git/': SSL certificate problem: self signed certificate in certificate chain
- git#github.com:doctrine/inflector.git
Cloning into 'C:\Users\User\my-project\vendor\doctrine\inflector'...
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

Categories