JackSmith
JackSmith

Reputation: 85

stream_context_create certificate verify failed

I'm trying to connect securely to this server bch.curalle.ovh port 50002

I have a certificate from letsencrypt which located at /var/www/mywebsite/fullchain.pem

my code:

$context = stream_context_create([ 'ssl' => [
                'verify_peer' => true,
                'verify_peer_name' => true,
                'cafile' => '/var/www/mywebsite/fullchain.pem',
            ]
    ]);

$connection = stream_socket_client("ssl://bch.curalle.ovh:50002" , $errorn , $errorstr , 5 , STREAM_CLIENT_CONNECT , $context);

Error Response:

SSL operation failed with code 1. OpenSSL Error messages:error:1416F086:SSL routines:tls_process_server_certificate:certificate verify failed 
Failed to enable crypto

I have changed my certificate to the one that CURL provides but the same exact error.

Upvotes: 1

Views: 772

Answers (1)

JackSmith
JackSmith

Reputation: 85

What cause this problem the following:

  • the server is not configured use SSL certificate (@Federkun).
  • Server that i'm connecting from has incorrect date.

I've fixed it by installing ntpdate and running ntpdate ntp.ubuntu.com on ubuntu

Upvotes: 1

Related Questions