8
Gentlemen,
I am trying to communicate with the recipe/SEFAZ server using an A1 certificate through an MVC5 C# application on an IIS 8 server, in the pool with my user identity. The certificate is installed and I have already performed the proper tests by connecting to the recipe directly through the Browser. However when making the request in the code I get the following error:
Request cancelled: Failed to create a secure channel for SSL/TLS.
The data of the request:
Parameters :
<xml version="1.0" encoding="UTF-8" >
 <consNFeDest versao="2.00 / 3.10" xmlns="http://www.portalfiscal.inf.br/nfe">
   <tpAmb>1</tpAmb>
   <cUF>31</cUF>
   <xServ>CONSULTAR NFE DEST</xServ>
    <CNPJ>000000000</CNPJ>
    <indNFe>0</indNFe>
   <indEmi>1</indEmi>
   <ultNSU>0</ultNSU>
</consNFeDest>
</xml>Service : https://www.nfe.fazenda.gov.br/NFeConsultaDest/NFeConsultaDest.asmx Version : 2.00 / 3.10
Code:
var parametros = Serializar<ConsultaStatusDoServico>();
    var certificado = PegarCertificado(loja);
    var ws = new SefazMG.NfeStatusServico2();
    var cabecalho = new nfeCabecMsg() { cUF = Contexto.ConfiguracoesDaNFE.Estado.ID.ToString(), versaoDados = Contexto.ConfiguracoesDaNFE.VersaoDoServicoDeStatus };
    var xEle = new XmlDocument(); 
    xEle.LoadXml(parametros);
    XmlNode node = xEle.DocumentElement;
    ws.ClientCertificates.Add(certificado);
    ws.Url = "https://www.nfe.fazenda.gov.br/NFeConsultaDest/NFeConsultaDest.asmx";
    ws.nfeCabecMsgValue = cabecalho;
    var nfeDadosMsg = new nfeDadosMsg();
    nfeDadosMsg.Any = new XmlNode[] { xEle.ChildNodes.Item(0) };
    var sb = new StringBuilder();
    nfeDadosMsg.Any = new XmlNode[] { xEle };
    nfeDadosMsg.Any[0] = node;
    try
    {
        var resposta = ws.nfeStatusServicoNF2(nfeDadosMsg);
        sb.AppendLine("Resposta : " + Serializar(resposta));
    }catch(Exception ex)
    {
        sb.AppendLine(ex.Message);
    }
Error:
Request cancelled: Failed to create a secure channel for SSL/TLS.
Hello friend, solved your problem?
– PauloHDSousa
Yes there was disagreement between the CNPJ and the Certificate
– Glauber A A
where you changed the contenttype ?
– Junior