Laminas\Soap\Client Error: "SoapClient::__doRequest(): Failed to enable crypto". PHP-FPM?

I am getting an error when making a request via the browser using the Laminas Soap library.
The same code would work via cli.
I get errors like:

  • Failed to enable crypto
  • OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed

One cause it could be was that we recently started using PHP-FPM with Apache, and before this, this code ran fine.
Is there some extra steps required for PHP_FPM to work in OpenSsl?

Some help or guidance would be appreciated

//context was added as a trouble shooting attempt, but had no affect
            $context = stream_context_create([
                'ssl' => [
                    // set some SSL/TLS specific options
                    'verify_peer' => false,
                    'verify_peer_name' => false,
                    'allow_self_signed' => true
                ]
            ]);
            
            
            // Using Zend Soap
            $xmlvar = new \SoapVar($request, XSD_ANYXML);
            $client = new Client($this->getWsdlFile(),
                array('local_cert'	=> $this->getCertFile(),                
                    'encoding' => $this->getEncoding(),
                    'soap_version'=> $this->getSoapVersion(),
                    'stream_context' => $context
                )
           );

Using PHP 7.3.
OpenSSL is installed in php.ini

Openssl

OpenSSL support enabled
OpenSSL Library Version OpenSSL 1.0.2u 20 Dec 2019
OpenSSL Header Version OpenSSL 1.0.2u 20 Dec 2019
Openssl default config /usr/local/openssl-1.0.2u/ssl/openssl.cnf
Directive Local Value Master Value
openssl.cafile no value no value
openssl.capath no value no value

This, for me was solved by specifying the location of the cafile and capath in the php.ini file:

openssl.cafile=/etc/ssl/certs/xxxx.crt
openssl.capath=/etc/ssl/certs/

Not sure what changed after the server upgrade that this suddenly was needed, perhaps this is a requirement of php-fpm.

Obviously needed to restart apache and probably php-fpm.