I thank my friend @Guilhermenascimento for his reply and @Bacco for helping in the chat to solve the problem.
I finally managed to solve!
Let’s take the necessary steps. I am using version 5.6 of PHP.
Once you have made all the necessary settings in apache, you need to make a configuration for PHP.
First, we need to find the location of the certificate file that PHP is reading. It can be seen through the function openssl_get_cert_locations
.
In my case, she returned the following:
[
"default_cert_file" => "/usr/lib/ssl/cert.pem",
"default_cert_file_env" => "SSL_CERT_FILE",
"default_cert_dir" => "/usr/lib/ssl/certs",
"default_cert_dir_env" => "SSL_CERT_DIR",
"default_private_dir" => "/usr/lib/ssl/private",
"default_default_cert_area" => "/usr/lib/ssl",
"ini_cafile" => "/usr/lib/ssl/cert.pem",
"ini_capath" => "",
]
Noting the value of default_cert_file
, you now know where PHP reads from cerificated intermediate.
Explaining in a very quick way the file cert.pem
contains a list of trusted certificates from each Certification Authority. It is called CA Bundle.
You must lower it in this link and move it to the location returned in default_cert_file
. Or else you can download it to another location and set, through the php.ini
, the location of your archive via the openssl.cafile
.
openssl.cafile = /caminho/do/cacert.pem
Every time you make a request via PHP via curl
or any other function using the wrapper https
, using the option verify_peer
, PHP will read this file to know which are the valid Certification Authority.
After these operations, if still the error shown in the question remains, you must manually add, at the end of the file, the intermediate code of your SSL certificate.
The user @Bacco recommended me to access by the browser itself and download this code.
See the image:
In my case, I chose the option Rapid SSL SHA256 CA
and exported the data. You can do this in any browser. The name will change according to your Certification Authority.
Important
From the moment you are adding a new CA to your system,
you’re saying you trust "blindly" that entity, so just do
that if really if it is a certificate that you are sure of
absolute origin and suitability.
Note: You can also find the code on the SSL service provider website, but in my case it worked better by downloading from the browser.
The code you will download from the certificate, will look something like this:
-----BEGIN CERTIFICATE-----
MIIDujCCAqKgAwIBAgILBAAAAAABD4Ym5g0wDQYJKoZIhvcNAQEFBQAwTDEgMB4GA1UECxMXR2xv
YmFsU2lnbiBSb290IENBIC0gUjIxEzARBgNVBAoTCkdsb2JhbFNpZ24xEzARBgNVBAMTCkdsb2Jh
bFNpZ24wHhcNMDYxM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BEP3ojY+x1J96relc8geMJgEtslQIxq/H5COEBkEveegeGTLg==
-----END CERTIFICATE-----
After that, edit the file marked as default_cert_file
in your PHP. In my case, I renamed it to cert.pem
after downloading. Now, add the certificate code you downloaded from the browser (or the CA certificate you’re using) and add it to the above mentioned file. It is recommended you put at the end of your.
After that you may need to restart Apache, but in my case, you didn’t need to.
Link to the CA Bundle:
https://curl.haxx.se/ca/cacert.pem
While SSL for lack authentication is mandatory. You can different for Heroku has PHP
– KingRider
see if that answer and this php wiki help you.
– Ivan Ferrer
PHP has a documentation for that reason.
– Ivan Ferrer
Try Openssl (http://php.net/manual/en/book.openssl.php) or Nginx can help tb
– KingRider