Search code examples
phpopensslcomposer-phpwindows-server

Composer, Windows Server and the infamous "SSL operation failed with code 1" error


I am currently facing a problem with Composer and, as I can understand it, OpenSSL. I spent the last couple of days trying various solutions that I found over the Web, but without any success.

To go straight to the point, when I try to get some packages with Composer, sometimes the following error is thrown:

... 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

What I read in other Stack Overflow posts is this problem is related to a certificate issue. Like it was suggested, I downloaded some certificates (https://raw.githubusercontent.com/bagder/ca-bundle/master/ca-bundle.crt and https://curl.haxx.se/ca/cacert.pem) and edited the values curl.cainfo and openssl.cafile in my php.ini file. Unfortunately, it did not work.

I checked environment variables and I don't have something like SSL_CERT_FILE or SSL_CERT_DIR. I tried to create them and assign a value to them without more success.

My system is a Windows Server 2019 and I installed PHP myself, but I also tried with a Wamp installation. The DLL for CURL and OpenSSL are here and the extensions are enabled in the php.ini files. I also encountered this error when I installed Composer, so I installed it manually.

I don't know where to look anymore. Does anybody have a suggestion?

Many thanks in advance.

Best regards,

SOLUTION

The solution was indeed simple: in our organization, we have our own root and intermediate certificate. I merged both of them with the pem file from https://curl.haxx.se/ca/cacert.pem, set the php.ini file accordingly, and it solved the problem.


Solution

  • The solution was indeed simple: in our organization, we have our own root and intermediate certificate. I merged both of them with the pem file from https://curl.haxx.se/ca/cacert.pem, set the php.ini file accordingly, and it solved the problem.