php – simplexml_load_file – Warning: simplexml_load_file(): SSL operation failed with code 1.
Error message:
Warning: simplexml_load_file(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed…
Solution:
- Download: ca-bundle.crt.
- Update code:
const URL = "https://service.domain.xy?";
const CA_FILE = "c:/php/cert/ca-bundle.crt";
private function loadXml(string $value1, string $value2)
{
$streamContent = stream_context_get_default([
'http' => ['proxy' => $this->proxy, 'request_fulluri' => true],
'ssl' => ['verify_peer' => true,'cafile' => self::CA_FILE],
]);
libxml_set_streams_context($streamContent);
return simplexml_load_file(self::URL . "param1=" . $value1 . "¶m2=" . $value2);
}