0
I am trying to carry out the communication with the WS of Curitiba (ISS Curitiba) for the sending and query of RPS lots (lots of NFS-e), but the WS always return me the error:
"E504 - Error: Service provider’s digital certificate is mandatory".
So my question is, what files should I send? The customer’s certificate (.pem or .pfx?), the public key? the private key? Someone who once had this job could help me?
I didn’t find much in the manuals and I haven’t been able to contact the support of the city.
I am using the Curl library (according to the code below):
curl_setopt($ch, CURLOPT_URL, '');
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSLCERT, $path.'_cert.pem'); // certificado do cliente
curl_setopt($ch, CURLOPT_SSLKEY, $path.'_priKEY.pem'); // chave privada
curl_setopt($ch, CURLOPT_SSLCERTTYPE, 'PEM');
curl_setopt($ch, CURLOPT_KEYPASSWD, '******'); // senha do certificado
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
Other technical details:
Headers:
$headers = [
'POST /Iss.NfseWebService/nfsews.asmx HTTP/1.1',
'HOST: '.$url,
'Content-Type: text/xml; charset=utf-8',
'Content-Length: '.strlen($xml),
'SOAPAction: http://www.e-governeapps2.com.br/RecepcionarLoteRps'
];
Creation of customer certificate:
// recebe o certificado pfx
openssl_pkcs12_read(file_get_contents('certificado.pfx'), $out, '******'));
// grava chave privada e o cartificado (sem a chave privada)
openssl_pkey_export_to_file($out['pkey'], $path.'_priKEY.pem');
openssl_x509_export_to_file($out['cert'], $path.'_cert.pem');