Hello,
I need to open a comunication with the server belove
CLEAR(WinHTTPRequest);
CREATE(WinHTTPRequest);
WinHTTPRequest.Open('POST','
https://www.sgate.anci.it/sgate-gas-web-services/services',FALSE);
WinHTTPRequest.SetClientCertificate('\LOCAL_MACHINE\My\1245-AUSA'); // SGATE ECERTIFICATE
WinHTTPRequest.SetCredentials('AUSA', 'GxG.XXXX', 0);
WinHTTPRequest.Send(XML);
well I have registered the ceritified by this command
winhttpcertcfg PFXFile -i -c LOCAL_MACHINE\My -a SV-IU-DBS -p XXXXXX
and after I have putted those register with mmc console
But don't works.
One my college had doing this code in C#, but in NAV C/AL I haven't found any of similar istructions :
SgateWebService ws = new SgateWebService();
ws.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "SGATE.cer"));
ws.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "GeoTrustPCA.cer"));
ws.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "GeoTrustEV.cer"));
ws.ClientCertificates.Add(new X509Certificate(pathCertificati + "389-YYYYY.pfx", "XXXXXX"));
ws.Timeout = 240 * 1000;
return ws;
He had not registered the certifieds in the comuter, but he had sent these how you can see.
Someone of you have never used certified .PFX with WinHTTPRequest?
every time I run the procedure this give me error : "You need to have a certified to connect...."
](*,) ](*,)
Comments
I have a problem, I need to use with HTTP request some certifieds, how you can see below in the senteces C/AL.
IF CREATE(WinHTTPRequest,TRUE,TRUE) THEN BEGIN
CREATE(XMLDoc,TRUE,TRUE);
WinHTTPRequest.Open('POST','http://www.sgate.anci.it/sgate-gas-web-services/services',FALSE);
WinHTTPRequest.SetClientCertificate('LOCAL_MACHINE\My\1245-AUSA');
WinHTTPRequest.SetClientCertificate('LOCAL_MACHINE\My\GeoTrustEV');
WinHTTPRequest.SetClientCertificate('LOCAL_MACHINE\My\GeoTrustPCA');
WinHTTPRequest.SetClientCertificate('LOCAL_MACHINE\My\SGATE');
WinHTTPRequest.SetCredentials('AUSA', 'mmmmm', 0);
WinHTTPRequest.SetRequestHeader('Content-type', 'text/xml; charset=utf-8');
WinHTTPRequest.SetTimeouts(360000,360000,360000,360000);
WinHTTPRequest.Send('<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"'
+ ' xmlns:xsd="http://www.sgate.ancitel.it/xsd/">'
+ ' <soapenv:Header/>'
+ ' <soapenv:Body>'
+ ' <xsd:richiestaPresaInCaricoLotto>'
+ ' <xsd:mittente>'
+ ' <xsd:login>AUSA</xsd:login>'
+ ' <xsd:password>yyyyyy</xsd:password>'
+ ' </xsd:mittente>'
+ ' <xsd:idUltimoLottoRicevutoCorrettamente>446983721</xsd:idUltimoLottoRicevutoCorrettamente>'
+ ' <xsd:numeroMessaggi>5</xsd:numeroMessaggi>'
+ ' </xsd:richiestaPresaInCaricoLotto>'
+ ' </soapenv:Body>'
+ '</soapenv:Envelope>');
IF WinHTTPRequest.Status <> 200 THEN
MESSAGE('Http Error ' + ' ' + FORMAT(WinHTTPRequest.Status) + ': ' + WinHTTPRequest.StatusText)
ELSE BEGIN
MESSAGE('Http Risposta ' + ' ' + WinHTTPRequest.StatusText);
XMLDoc.async := FALSE;
XMLDoc.load(WinHTTPRequest.ResponseBody);
XMLNode := XMLDoc.selectSingleNode('//Soap:Envelope/Soap:Body/'+ Text002 +'_Result/return_value/');
IF NOT ISCLEAR(XMLNode) THEN
MESSAGE(XMLNode.text)
ELSE BEGIN
XMLDoc.save('C:\Dati\Lotti\response.xml');
HYPERLINK('C:\Dati\Lotti\response.xml');
END;
END;
CLEAR(XMLDoc);
END;
I had register the certifieds by prompt command :
1) winhttpcertcfg PFXFile -i -c LOCAL_MACHINE\My -a SV-IU_SERVER -p PFXPassword
2) winhttpcertcfg -g -c LOCAL_MACHINE\My -s "1245-AUSA" -a "administrator"
3) winhttpcertcfg -g -c LOCAL_MACHINE\My -s "1245-AUSA" -a "NetworkService"
4) winhttpcertcfg -g -c LOCAL_MACHINE\My -a "1245-AUSA" -a "ASPNET"
5) winhttpcertcfg -i -c LOCAL_MACHINE\My -a "administrator"
afert, I had registerd the certifieds, using MMC interface, but didn't works.
My colleague, that works in C#, had resolved sending, by DLL proxy webservice, the certicates in this mode :
SgateWebService ws = new SgateWebService();
ws.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "SGATE.cer"));
ws.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "GeoTrustPCA.cer"));
ws.ClientCertificates.Add(X509Certificate.CreateFromCertFile(pathCertificati + "GeoTrustEV.cer"));
ws.ClientCertificates.Add(new X509Certificate(pathCertificati + "ooooo.pfx", "ppooooo"));
ws.Timeout = 240 * 1000;
Now I would know if in C/AL exist a DLL DotNet or Automation for use "X509Certificate", and apply the same solution of my colleague, sending the certifeds without reading thwse from server's register by this sentence :
WinHTTPRequest.SetClientCertificate('LOCAL_MACHINE\My\1245-AUSA');
WinHTTPRequest.SetClientCertificate('LOCAL_MACHINE\My\GeoTrustEV');
WinHTTPRequest.SetClientCertificate('LOCAL_MACHINE\My\GeoTrustPCA');
WinHTTPRequest.SetClientCertificate('LOCAL_MACHINE\My\SGATE');
](*,)