Srs,
I'm trying to communicate with the recipe server / SEFAZ using an A1 certificate through an MVC5 C # application on an IIS 8 server, in the pool with my user's identity. The certificate is installed and I have already performed the tests by connecting directly to the recipe from the Browser. However when doing the request in the code I get the following error:
The request was aborted: A secure channel for SSL / TLS could not be created.
The request data:
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: link 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:
The request was aborted: A secure channel for SSL / TLS could not be created.