Error consuming webservice NFSe with mutual authentication - handshaking

0

I have a problem to consume the electronic invoice webservice of the city of Sertãozinho. The server in this NFS uses Tomcat with mutual authentication (handshaking). The production server address is:

    [https://nfe.sertaozinho.sp.gov.br:8443/tbw/services/nfseSOAP?wsdl][1]

In the development machine I installed the certificates provided by the City Hall, composed of the root keys of the certifying authorities and the public key of the city hall. The files provided are:

  • AC-Secretariat-of-Federal-Revenue-of-Brazil-v3.cer
  • ACVALID-RFB.cer
  • Certifying Authority-Root-Brazilian-V2.cer
  • Cert_pms-public.cer (SERTÃOZINHO PREFECTURE)

All of these certificates have been installed for both the "CurrentUser" and "LocalMachine". I also attempted to install the certificates in the "Personal" and "Trusted Root Certification Authorities" folders.

In addition to these certificates, I also use the client certificate to sign the NFSE XML (pfx file).

I am using the client certificate to sign the note XML and the city hall certificate to encrypt the TLS communication. Here is the code that configures the communication, gets the certificate and executes the consumption of the WS method:

try
{
    // Tentativas de configurar a comunicação (códigos sugeridos por outros blogs)
    ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true;
    ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls;

    BasicHttpBinding myBinding = new BasicHttpBinding();
    myBinding.Security.Mode = BasicHttpSecurityMode.Transport;
    myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Certificate;

    // A função ConfigurarWS apenas cria o EndPoint com o endereço de produção/homologação
    EndpointAddress endPoint = ConfigurarWS(ref myBinding);

    // instancia o proxy do webservice
    wsSertaozinhoProd.nfseClient nfseClient = new wsSertaozinhoProd.nfseClient(myBinding, endPoint);

    // atribui o certificado da prefeitura para o canal seguro
    // a função GetCertForWebService2 está abrindo o repositório de certificados em LocalMachine e Root (Autoridades de Certificação Raiz Confiáveis) e pesquisando o certificado por número de série
    nfseClient.ClientCredentials.ClientCertificate.Certificate = Security.GetCertForWebService2("2D279236B9F1B43B");  // MUNICIPIO

    // atribui as informações de cabeçalho e dados da nota fiscal
    wsSertaozinhoProd.input inputobj = new wsSertaozinhoProd.input();
    inputobj.nfseCabecMsg = GerarCabRecepcionarLoteRpsSincrono();
    inputobj.nfseDadosMsg = strXML;

    // executa o método de envio da nota e processa o retorno
    return LerXMLResposta(nfseClient.GerarNfse(inputobj).outputXML);
} 
catch (Exception ex)
{
    csResult.bValidacao = false;
    csResult.strTipoRetorno = "ERROCOMUNICACAO";

    Util.LogEmArquivo.WriteLogEntry("Falha no envio da nota, método TramissaoWS() tentativa " + iTentativa + Environment.NewLine + " Exception: " + ex.Message, EventType.Error);
    Util.LogEmTela.AdicionaMsg("ERRO: " + ex.Message);
    Util.LogEmTela.AdicionaMsg("Tentando novamente, tentativa " + (iTentativa + 1) + " de " + QtdeTentativas);
    if (iTentativa == InternalConfig.Tentativas)
    {
        Util.LogEmTela.AdicionaMsg("Não foi possível enviar a nota fiscal, tentativas esgotadas");
        return csResult;
    }
}

The error that is occurring is:

  • Error: Could not establish secure channel for SSL / TLS with authority 'nfe.sertaozinho.sp.gov.br:8443'.
  • InnerException: Request aborted: Could not create a secure channel for SSL / TLS.

I have enabled the trace for System.Net, System.Net.HttpListener, System.Net.Sockets, and System.Net.Cache. Below is an excerpt from the log generated by the trace, where I highlighted in bold the points I was focusing on to try to solve the problem. A catchy message is when it informs that the certificate could not be found.

Does the configuration I am performing suffice for this mutual communication format? I tried to inform the client's certificate to create the secure communication channel, but another error occurred, stating that the certificate type is not compatible with the communication type.

 System.Net Information: 0 : [7532] O tipo de instalação de SO atual é 'Client'.
      ProcessId=12476
      DateTime=2018-04-10T20:14:12.4377543Z
  System.Net Verbose: 0 : [7532] WebRequest::Create(https://nfe.sertaozinho.sp.gov.br:8443/tbw/services/nfseSOAP)
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.3489598Z
  System.Net Verbose: 0 : [7532] HttpWebRequest#13040701::HttpWebRequest(https://nfe.sertaozinho.sp.gov.br:8443/tbw/services/nfseSOAP#-1597284356)
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.3489598Z
  System.Net Information: 0 : [7532] RAS com suporte: True
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.3645855Z
  System.Net Verbose: 0 : [7532] Exiting HttpWebRequest#13040701::HttpWebRequest() 
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.3802118Z
  System.Net Verbose: 0 : [7532] Exiting WebRequest::Create()   -> HttpWebRequest#13040701
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.3802118Z
  System.Net Error: 0 : [7532] Não é possível recuperar as configurações de proxy para o Uri 'https://nfe.sertaozinho.sp.gov.br:8443/tbw/services/nfseSOAP'. Código de erro: 12180.
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.4114633Z
  System.Net Verbose: 0 : [7532] ServicePoint#64906717::ServicePoint(nfe.sertaozinho.sp.gov.br:8443)
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.4114633Z
  System.Net Information: 0 : [7532] Associating HttpWebRequest#13040701 with ServicePoint#64906717
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.4114633Z
  System.Net Verbose: 0 : [7532] HttpWebRequest#13040701::GetRequestStream()
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.6936907Z
  System.Net Information: 0 : [7532] Associating Connection#42644125 with HttpWebRequest#13040701
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.7093164Z
  System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Socket(AddressFamily#2)
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.7249422Z
  System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Socket() 
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.7249422Z
  System.Net.Sockets Verbose: 0 : [7532] Socket#12507741::Socket(AddressFamily#23)
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.7249422Z
  System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#12507741::Socket() 
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.7340231Z
  System.Net.Sockets Verbose: 0 : [7532] DNS::TryInternalResolve(nfe.sertaozinho.sp.gov.br)
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.7370249Z
  System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Connect(187.45.156.18:8443#312216896)
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.7480326Z
  System.Net.Sockets Information: 0 : [7532] Socket#3578669 - Conexão criada de 192.168.2.18:13287 para 187.45.156.18:8443.
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.8106960Z
  System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Connect() 
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.8106960Z
  System.Net.Sockets Verbose: 0 : [7532] Socket#12507741::Close()
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.8263223Z
  System.Net.Sockets Verbose: 0 : [7532] Socket#12507741::Dispose()
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.8263223Z
  System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#12507741::Close() 
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.8263223Z
  System.Net Information: 0 : [7532] Connection#42644125 - Conexão criada de 192.168.2.18:13287 para 187.45.156.18:8443.
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.8263223Z
  System.Net Information: 0 : [7532] TlsStream#43055348::.ctor(host=nfe.sertaozinho.sp.gov.br, #certs=1)
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.8263223Z
  System.Net Information: 0 : [7532] Associating HttpWebRequest#13040701 with ConnectStream#20438820
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.8419469Z
  System.Net Verbose: 0 : [7532] Exiting HttpWebRequest#13040701::GetRequestStream()    -> ConnectStream#20438820
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.8419469Z
  System.Net Verbose: 0 : [7532] ConnectStream#20438820::Write()
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.8419469Z
  System.Net Verbose: 0 : [7532] Data from ConnectStream#20438820::Write
      ProcessId=12476
      DateTime=2018-04-10T20:14:17.8419469Z

  ... DADOS DA NFE ...

  System.Net Verbose: 0 : [7532] Exiting ConnectStream#20438820::Write() 
      ProcessId=12476
      DateTime=2018-04-10T20:14:18.0763383Z
  System.Net Verbose: 0 : [7532] ConnectStream#20438820::Close()
      ProcessId=12476
      DateTime=2018-04-10T20:14:18.0763383Z
  System.Net Verbose: 0 : [7532] Exiting ConnectStream#20438820::Close() 
      ProcessId=12476
      DateTime=2018-04-10T20:14:18.0919635Z
  System.Net Verbose: 0 : [7532] HttpWebRequest#13040701::GetResponse()
      ProcessId=12476
      DateTime=2018-04-10T20:14:18.0919635Z
  System.Net Information: 0 : [7532] HttpWebRequest#13040701 - Request: POST /tbw/services/nfseSOAP HTTP/1.1
      ProcessId=12476
      DateTime=2018-04-10T20:14:18.0919635Z
  System.Net Information: 0 : [7532] ConnectStream#20438820 - Enviando cabeçalhos
  {
  Content-Type: text/xml; charset=utf-8
  VsDebuggerCausalityData: uIDPoyjb1qfQy7dOrMLMbyXyjYUAAAAAJpB1DKi1xkiXtyLcEon0joshTOqQUHtDtcASL4o4uDoACQAA
  SOAPAction: "http://nfse.abrasf.org.br/GerarNfse"
  Host: nfe.sertaozinho.sp.gov.br:8443
  Content-Length: 12410
  Expect: 100-continue
  Accept-Encoding: gzip, deflate
  Connection: Keep-Alive
  }.
      ProcessId=12476
      DateTime=2018-04-10T20:14:18.0919635Z
  System.Net Information: 0 : [7532] SecureChannel#32685253::.ctor(hostname=nfe.sertaozinho.sp.gov.br,
#clientCertificates=1, encryptionPolicy=RequireEncryption)
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1075898Z
 System.Net Information: 0 : [7532] Enumerando os pacotes de segurança:
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1119901Z
 System.Net Information: 0 : [7532]     Negotiate
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1149924Z
 System.Net Information: 0 : [7532]     NegoExtender
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1169943Z
 System.Net Information: 0 : [7532]     Kerberos
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1199961Z
 System.Net Information: 0 : [7532]     NTLM
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1219974Z
 System.Net Information: 0 : [7532]     TSSSP
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1239988Z
 System.Net Information: 0 : [7532]     pku2u
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1260002Z
 System.Net Information: 0 : [7532]     WDigest
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1290019Z
 System.Net Information: 0 : [7532]     Schannel
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1301347Z
 System.Net Information: 0 : [7532]     Microsoft Unified Security Protocol Provider
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1301347Z
 System.Net Information: 0 : [7532]     Default TLS SSP
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1301347Z
 System.Net Information: 0 : [7532]     CREDSSP
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1301347Z
 System.Net Information: 0 : [7532] SecureChannel#32685253 - Tentativa de reiniciar a sessão usando o certificado fornecido pelo usuário: [Version]
   V3

 [Subject]
   CN=MUNICIPIO DE SERTAOZINHO:45371820000128, OU=AR MAC BR, OU=RFB e-CNPJ A1, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, L=SERTAOZINHO, S=SP, C=BR
   Simple Name: MUNICIPIO DE SERTAOZINHO:45371820000128
   Email Name: [email protected]
   DNS Name: MUNICIPIO DE SERTAOZINHO:45371820000128

 [Issuer]
   CN=AC VALID RFB, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, C=BR
   Simple Name: AC VALID RFB
   DNS Name: AC VALID RFB

 [Serial Number]
   2D279236B9F1B43B

 [Not Before]
   08/03/2018 18:09:59

 [Not After]
   08/03/2019 18:09:59

 [Thumbprint]
   640FA8E12C374BF9C4EAD743FB51FB1F8D2351B6

 [Signature Algorithm]
   sha256RSA(1.2.840.113549.1.1.11)

 [Public Key]
   Algorithm: RSA
   Length: 2048
   Key Blob: 30 82 01 0a 02 82 01 01 00 bd 68 20 34 8d 80 3a c1 31 75 32 9a 76 e4 8b 29 cb 80 8e fa bd 78 dc 39 96 e7 d9 a5 d3 08 89 0f 91 f7 c7 77 b0 1b 9b 8a 21 7f 86 e2 ae 0a 13 4f ee 1e 6d 16 08 7e ee b8 7c fd 77 3a ....
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1457647Z
 System.Net Information: 0 : [7532] SecureChannel#32685253 - Deixado com 1 certificados de cliente dos quais escolher.
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1457647Z
 System.Net Information: 0 : [7532] SecureChannel#32685253 - Tentando encontrar um certificado correspondente no repositório de certificados.
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1457647Z
 System.Net Information: 0 : [7532] SecureChannel#32685253 - Localizando a chave privada para o certificado: [Version]
   V3

 [Subject]
   CN=MUNICIPIO DE SERTAOZINHO:45371820000128, OU=AR MAC BR, OU=RFB e-CNPJ A1, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, L=SERTAOZINHO, S=SP, C=BR
   Simple Name: MUNICIPIO DE SERTAOZINHO:45371820000128
   Email Name: [email protected]
   DNS Name: MUNICIPIO DE SERTAOZINHO:45371820000128

 [Issuer]
   CN=AC VALID RFB, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, C=BR
   Simple Name: AC VALID RFB
   DNS Name: AC VALID RFB

 [Serial Number]
   2D279236B9F1B43B

 [Not Before]
   08/03/2018 18:09:59

 [Not After]
   08/03/2019 18:09:59

 [Thumbprint]
   640FA8E12C374BF9C4EAD743FB51FB1F8D2351B6

 [Signature Algorithm]
   sha256RSA(1.2.840.113549.1.1.11)

 [Public Key]
   Algorithm: RSA
   Length: 2048
   Key Blob: 30 82 01 0a 02 82 01 01 00 bd 68 20 34 8d 80 3a c1 31 75 32 9a 76 e4 8b 29 cb 80 8e fa bd 78 dc 39 96 e7 d9 a5 d3 08 89 0f 91 f7 c7 77 b0 1b 9b 8a 21 7f 86 e2 ae 0a 13 4f ee 1e 6d 16 08 7e ee b8 7c fd 77 3a ....
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1613889Z
 System.Net Information: 0 : [7532] SecureChannel#32685253 - Não é possível encontrar o certificado no repositório LocalMachine ou CurrentUser.
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1613889Z
 System.Net Information: 0 : [7532] AcquireCredentialsHandle(package = Microsoft Unified Security Protocol Provider, intent  = Outbound, scc     = System.Net.SecureCredential)
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1770124Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = (null), targetName = nfe.sertaozinho.sp.gov.br, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1770124Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(In-Buffer length=0, Out-Buffer length=139, retornou o código=ContinueNeeded).
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1770124Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Send()
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1770124Z
 System.Net.Sockets Verbose: 0 : [7532] Data from Socket#3578669::Send
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.1770124Z
 System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Send()  -> Int32#139
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.2082655Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Receive()
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.2082655Z
 System.Net.Sockets Verbose: 0 : [7532] Data from Socket#3578669::Receive
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.2961358Z
 System.Net.Sockets Verbose: 0 : [7532] 00000000 : 16 03 01 40 00                                  : ...@.
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.3117593Z
 System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Receive()   -> Int32#5
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.3117593Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Receive()
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.3117593Z
 System.Net.Sockets Verbose: 0 : [7532] Data from Socket#3578669::Receive
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.3117593Z
 System.Net.Sockets Verbose: 0 : [7532] (printing 1024 out of 2875)
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.3117593Z

 .....

 System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Receive()   -> Int32#2875
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.4680188Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Receive()
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.4680188Z
 System.Net.Sockets Verbose: 0 : [7532] Data from Socket#3578669::Receive
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.4836451Z

 ... DADOS NFE ...

 System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Receive()   -> Int32#13509
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.6399046Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = dbec100:7aa8d68, targetName = nfe.sertaozinho.sp.gov.br, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.6399046Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, retornou o código=ContinueNeeded).
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.6399046Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Receive()
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.6399046Z
 System.Net.Sockets Verbose: 0 : [7532] Data from Socket#3578669::Receive
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.6399046Z
 System.Net.Sockets Verbose: 0 : [7532] 00000000 : 16 03 01 40 00                                  : ...@.
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.6555309Z
 System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Receive()   -> Int32#5
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.6555309Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Receive()
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.6555309Z
 System.Net.Sockets Verbose: 0 : [7532] Data from Socket#3578669::Receive
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.6555309Z
 System.Net.Sockets Verbose: 0 : [7532] (printing 1024 out of 16384)
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.6555309Z

 .....

 System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Receive()   -> Int32#16384
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.8241929Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = dbec100:7aa8d68, targetName = nfe.sertaozinho.sp.gov.br, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.8261948Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, retornou o código=ContinueNeeded).
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.8273951Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Receive()
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.8273951Z
 System.Net.Sockets Verbose: 0 : [7532] Data from Socket#3578669::Receive
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.8273951Z
 System.Net.Sockets Verbose: 0 : [7532] 00000000 : 16 03 01 01 B7                                  : .....
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.8273951Z
 System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Receive()   -> Int32#5
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.8273951Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Receive()
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.8273951Z
 System.Net.Sockets Verbose: 0 : [7532] Data from Socket#3578669::Receive
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.8273951Z

 ......

 System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Receive()   -> Int32#439
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.8898985Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = dbec100:7aa8d68, targetName = nfe.sertaozinho.sp.gov.br, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9055248Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, retornou o código=CredentialsNeeded).
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9055248Z
 System.Net Information: 0 : [7532] SecureChannel#32685253 - Há certificados fornecidos pelo usuário. O servidor especificou 181 emissor(es). Procurando certificados que correspondam a um dos emissores.
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9211506Z
 System.Net Information: 0 : [7532] SecureChannel#32685253 - Certificado selecionado: [Version]
   V3

 [Subject]
   CN=MUNICIPIO DE SERTAOZINHO:45371820000128, OU=AR MAC BR, OU=RFB e-CNPJ A1, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, L=SERTAOZINHO, S=SP, C=BR
   Simple Name: MUNICIPIO DE SERTAOZINHO:45371820000128
   Email Name: [email protected]
   DNS Name: MUNICIPIO DE SERTAOZINHO:45371820000128

 [Issuer]
   CN=AC VALID RFB, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, C=BR
   Simple Name: AC VALID RFB
   DNS Name: AC VALID RFB

 [Serial Number]
   2D279236B9F1B43B

 [Not Before]
   08/03/2018 18:09:59

 [Not After]
   08/03/2019 18:09:59

 [Thumbprint]
   640FA8E12C374BF9C4EAD743FB51FB1F8D2351B6

 [Signature Algorithm]
   sha256RSA(1.2.840.113549.1.1.11)

 [Public Key]
   Algorithm: RSA
   Length: 2048
   Key Blob: 30 82 01 0a 02 82 01 01 00 bd 68 20 34 8d 80 3a c1 31 75 32 9a 76 e4 8b 29 cb 80 8e fa bd 78 dc 39 96 e7 d9 a5 d3 08 89 0f 91 f7 c7 77 b0 1b 9b 8a 21 7f 86 e2 ae 0a 13 4f ee 1e 6d 16 08 7e ee b8 7c fd 77 3a ....
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9524031Z
 System.Net Information: 0 : [7532] SecureChannel#32685253 - Deixado com 1 certificados de cliente dos quais escolher.
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9524031Z
 System.Net Information: 0 : [7532] SecureChannel#32685253 - Tentando encontrar um certificado correspondente no repositório de certificados.
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9524031Z
 System.Net Information: 0 : [7532] SecureChannel#32685253 - Localizando a chave privada para o certificado: [Version]
   V3

 [Subject]
   CN=MUNICIPIO DE SERTAOZINHO:45371820000128, OU=AR MAC BR, OU=RFB e-CNPJ A1, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, L=SERTAOZINHO, S=SP, C=BR
   Simple Name: MUNICIPIO DE SERTAOZINHO:45371820000128
   Email Name: [email protected]
   DNS Name: MUNICIPIO DE SERTAOZINHO:45371820000128

 [Issuer]
   CN=AC VALID RFB, OU=Secretaria da Receita Federal do Brasil - RFB, O=ICP-Brasil, C=BR
   Simple Name: AC VALID RFB
   DNS Name: AC VALID RFB

 [Serial Number]
   2D279236B9F1B43B

 [Not Before]
   08/03/2018 18:09:59

 [Not After]
   08/03/2019 18:09:59

 [Thumbprint]
   640FA8E12C374BF9C4EAD743FB51FB1F8D2351B6

 [Signature Algorithm]
   sha256RSA(1.2.840.113549.1.1.11)

 [Public Key]
   Algorithm: RSA
   Length: 2048
   Key Blob: 30 82 01 0a 02 82 01 01 00 bd 68 20 34 8d 80 3a c1 31 75 32 9a 76 e4 8b 29 cb 80 8e fa bd 78 dc 39 96 e7 d9 a5 d3 08 89 0f 91 f7 c7 77 b0 1b 9b 8a 21 7f 86 e2 ae 0a 13 4f ee 1e 6d 16 08 7e ee b8 7c fd 77 3a ....
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9524031Z
 System.Net Information: 0 : [7532] SecureChannel#32685253 - Não é possível encontrar o certificado no repositório LocalMachine ou CurrentUser.
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9524031Z
 System.Net Information: 0 : [7532] Usando o identificador de credencial armazenado em cache.
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9680283Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = dbec100:7aa8d68, targetName = nfe.sertaozinho.sp.gov.br, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9680283Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=141, retornou o código=ContinueNeeded).
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9680283Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Send()
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9680283Z
 System.Net.Sockets Verbose: 0 : [7532] Data from Socket#3578669::Send
     ProcessId=12476
     DateTime=2018-04-10T20:14:18.9680283Z

 .....

 System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Send()  -> Int32#141
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0149071Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Receive()
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0149071Z
 System.Net.Sockets Verbose: 0 : [7532] Data from Socket#3578669::Receive
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0305350Z
 System.Net.Sockets Verbose: 0 : [7532] 00000000 : 15 03 01 00 02                                  : .....
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0305350Z
 System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Receive()   -> Int32#5
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0461591Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Receive()
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0461591Z
 System.Net.Sockets Verbose: 0 : [7532] Data from Socket#3578669::Receive
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0461591Z
 System.Net.Sockets Verbose: 0 : [7532] 00000005 : 02 2A                                           : .*
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0461591Z
 System.Net.Sockets Verbose: 0 : [7532] Exiting Socket#3578669::Receive()   -> Int32#2
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0461591Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(credential = System.Net.SafeFreeCredential_SECURITY, context = dbec100:7aa8d68, targetName = nfe.sertaozinho.sp.gov.br, inFlags = ReplayDetect, SequenceDetect, Confidentiality, AllocateMemory, InitManualCredValidation)
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0461591Z
 System.Net Information: 0 : [7532] InitializeSecurityContext(In-Buffers count=2, Out-Buffer length=0, retornou o código=CertUnknown).
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0617859Z
 System.Net.Sockets Verbose: 0 : [7532] Socket#3578669::Dispose()
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0617859Z
 System.Net Error: 0 : [7532] Exceção em HttpWebRequest#13040701:: - A solicitação foi anulada: Não foi possível criar um canal seguro para SSL/TLS..
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0617859Z
 System.Net Error: 0 : [7532] Exceção em HttpWebRequest#13040701::GetResponse - A solicitação foi anulada: Não foi possível criar um canal seguro para SSL/TLS..
     ProcessId=12476
     DateTime=2018-04-10T20:14:19.0617859Z
    
asked by anonymous 11.04.2018 / 16:03

1 answer

0

Hello

I was able to solve the problem.

Solution: When I installed the client's digital certificate in the Windows repository, I did not check the box Mark this key as exportable. This will enable the backup or transport of the keys later . From the moment I activated this feature, webservice was able to validate the communication channel and enabled the transmission of NFS-e.

Thank you!

Rodrigo Duarte | ONCLICK Systems

    
12.04.2018 / 22:02