The problem is the address certificate https://sistemasweb.sefaz.ba.gov.br/sistemas/DTE/Contribuinte/SSL/ASLibrary/Login, it is invalid, but it can also occur, even if they fix the site, your PHP not having the certificates configured, for future chance try this /a/137009/3635, who would stay:
$context = stream_context_create(array(
"ssl"=>array(
"cafile" => "/path/cacert.pem",
"verify_peer"=> true,
"verify_peer_name"=> true
)
));
libxml_set_streams_context($context);
Or configure php.ini properly:
openssl.cafile=/path/cacert.pem
And restart Apache or Nginx. However it is as said, the above solutions will not work, are for when the site you are trying to access is with the certificate fixed, for now you can disable the SSL check so:
$context = stream_context_create(array(
"ssl"=>array(
'verify_peer' => false,
'verify_peer_name' => false
)
));
libxml_set_streams_context($context);
$html = new DOMDocument();
$html->loadHTMLFile("https://sistemasweb.sefaz.ba.gov.br/sistemas/DTE/Contribuinte/SSL/ASLibrary/Login");
$dado = $html->getElementsByTagName('__EVENTVALIDATION');
echo $dado;
If eventually the libxml_set_streams_context
not working can try changing the approach to:
$context = stream_context_create(array(
"ssl"=>array(
'verify_peer' => false,
'verify_peer_name' => false
)
));
$conteudosite = file_get_contents("https://sistemasweb.sefaz.ba.gov.br/sistemas/DTE/Contribuinte/SSL/ASLibrary/Login", false, $context);
$html = new DOMDocument();
$html->loadHTML($conteudosite);
$dado = $html->getElementsByTagName('__EVENTVALIDATION');
echo $dado;
The certificate is valid, but the certification authority that issued it is not recognised (the key corresponds to the certificate, but the verification on the list of recognized authorities failed). They are quite different things. The answer deserves a small adjustment in this sense.
– Bacco