Issuance of NF-e 4.0: Goiás (C # / Net)

1

I'm updating the NF-e communication for some clients and in general I'm not having problems for licensors like Rio Grande do Sul and São Paulo, for example.

But I can not make Goias work at all.

Namely, I made a simple Console Application, in which I inserted a service reference for the Authorization Service of Goiás NFe (requires digital certificate):

link

The error happens whenever I call the remote method "nfeAuthorization": System.ServiceModel.Security.SecurityNegotiationException: 'A secure channel for SSL / TLS with authority' homolog.sefaz.go.gov.br 'could not be established. '

Namely: the certificate chain is properly installed.

OnethingIfoundstrangeisthatalthoughthewsdlisonanHTTPS,theendpointresolvedbytheserviceishttp.

<client><endpointaddress="http://homolog.sefaz.go.gov.br:80/nfe/services/NFeAutorizacao4"
            binding="customBinding" bindingConfiguration="NFeAutorizacao4ServiceBinding"
            contract="Hom.Goias.NFeAutorizacao4Service" name="NFeAutorizacao4Port" />
</client>

If I force https, my error is timeout.

My code is as follows:

    static void Main(string[] args)
    {
        System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

        var client = new Hom.Goias.NFeAutorizacao4ServiceClient();


        client.ClientCredentials.ClientCertificate.Certificate =
            new System.Security.Cryptography.X509Certificates.X509Certificate2(@"D:\Projects\XPTO\CERT.pfx", "SENHADOCERTIFICADO");


        var xdoc = new XmlDocument();

        xdoc.Load(@"d:\Projects\XPTO\nfe-go.xml");

        var resp = client.nfeAutorizacaoLote(xdoc);

        Console.ReadKey();


    }

Any suggestions are welcome!

    
asked by anonymous 25.07.2018 / 00:54

1 answer

0

I did it!

In the end it was more a matter of adjusting the bindings themselves!

When I change the address to "https" I need to get port 80. In addition, I had to add some information about the transport. But in the end, it worked!

<system.serviceModel>
    <bindings>
      <customBinding>
        <binding name="NFeAutorizacao4ServiceBinding">
          <textMessageEncoding messageVersion="Soap12" />
          <httpsTransport authenticationScheme="Digest" requireClientCertificate="true"/>
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="https://homolog.sefaz.go.gov.br/nfe/services/NFeAutorizacao4"
          binding="customBinding" bindingConfiguration="NFeAutorizacao4ServiceBinding"
          contract="Hom.Goias.NFeAutorizacao4Service" name="NFeAutorizacao4Port" />
    </client>
  </system.serviceModel>
    
25.07.2018 / 01:43