PHP - CURL HTTPS Request - Nfse Curitiba

Asked

Viewed 671 times

0

I’m doing an integration with Webservice for sending RPS, for NFS-e, I’m using the PHP programming language, and the CURL library. In this integration is mandatory when making any request sending the digital certificate, this we already have and we are sending in the parameter (CURLOPT_SSLKEY) the absolute path of the certificate.

The CURL parameters are as follows:

    $_options = array (
        CURLOPT_URL => 'https://pilotoisscuritiba.curitiba.pr.gov.br/nfse_ws/NfseWs.asmx?WSDL',
        CURLOPT_CONNECTTIMEOUT => 60,
        CURLOPT_TIMEOUT => 60,
        CURLOPT_RETURNTRANSFER  => true,
        CURLOPT_SSL_VERIFYHOST => 2,
        CURLOPT_SSL_VERIFYPEER => 0,
        CURLOPT_SSLKEY  => /var/cert/cert.pem, // certificado
        CURLOPT_POSTFIELDS => $_content,
        CURLOPT_HTTPHEADER => $_header
    );

I have the following return :

<?xml version="1.0"?>
<EnviarLoteRpsResposta xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<NumeroLote xsi:nil="true"/>
	<DataRecebimento xsi:nil="true"/>
	<ListaMensagemRetorno>
		<MensagemRetorno>
			<Codigo>E504</Codigo>
			<Mensagem>O certificado digital do prestador de serviços é obrigatório.</Mensagem>
			<Correcao>Envie junto a requisição do serviço o certificado digital do prestador de serviços.</Correcao>
		</MensagemRetorno>
	</ListaMensagemRetorno>
</EnviarLoteRpsResposta>

Has anyone been through this before and/or has any idea how to solve this problem ?

  • Must pass as string '/var/cert/cert.pem' first. Now, it may be that beyond the SSLKEY (that the private key) needs to specify the public key (using the SSLCERT). And of course, you need to set the private key password (KEYPASSWD), if there is any. After all, when you turn off the VERIFYPEER it ceases to use/verify the CAINFO, creating security problems, but that’s beside the point.

  • I’m sending it like this now: $_options = array ( CURLOPT_URL => $this->_wsdl, CURLOPT_CONNECTTIMEOUT => 60, CURLOPT_TIMEOUT => 60, CURLOPT_RURNTRANSFER => true, CURLOPT_SL_VERIFYHOST => 2, URLOPT_SSL_VERIFYPEPER => 0, CURLOPT_SSLCERT => $this->publicKey, // Public key CURLOPT_SLKEY => $this->privateKey, // Private key CURLOPT_KEYPASSWD => '******', CURLOPT_POSTFILDS => $_content, CURLOPT_HTTHEADER => $_header&#Xa#; );

  • And now it’s returning me an html page : <div id="content"> <div class="content-container"> <fieldset> <H2>403 - Forbidden: Access is denied. </H2> <H3>You do not have permission to view this directory or page using the credentials that you supplied. </H3> </fieldset> </div> </div>

  • You know what you can be now ?

1 answer

-1

Good morning, good afternoon or good night depends on the time you read.

I had the same problem recently when I contacted the staff of the Iss Curitiba was discovered that the problem was in the certificate.

So my client had to make a new one with the ICP Brazil standard.

In my case it solved.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.