LukePOLO
LukePOLO

Reputation: 1118

PHP verify failed with LetsEncrypt

Having an issue when trying to read a stream :

$result = file_get_contents($url, false, stream_context_create(
    ['http' => ['timeout' => (float) $this->options['timeout']]]
));

SSL operation failed with code 1. OpenSSL Error messages:

error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

Before anyone answers i am not going to do

 "ssl"=>array(
        "verify_peer"=>false,
        "verify_peer_name"=>false,
    ),

Am hoping someone else has used letsencrypt and has some proper way of making sure its validated.

feel free to check my cert on my domain lukepolo.com

Upvotes: 5

Views: 3544

Answers (2)

LukePOLO
LukePOLO

Reputation: 1118

openssl.cafile= curl.cainfo=

in your php.ini , you need both

Upvotes: 3

Machavity
Machavity

Reputation: 31634

You'll probably have to install the CA certificate (this page has links to download the CA file). You might have to try each of the various signed to get it to work. Get the PEM version and save it to your server and then change your code like so

$result = file_get_contents($url, false, stream_context_create(
    [
        'http' => ['timeout' => (float) $this->options['timeout']],
        'ssl' => ['cafile' => '/path/to/file.pem']
    ]
));

Upvotes: 1

Related Questions