Hi everyone. I wonder if someone has some experiences with adding digital signature to xml files. What I want to do is, to sign the xml document with digital certificate (pfx file) installed on local machine. I saw xml dom 5 library has some of the required methods to do the signing, but I just can't figure out how to use it properly, so any suggestion is highly appreciated, thanks.
0
Comments
After installing the certificate you can try something like this in Navision:
WinHTTPReq: Automation 'Microsoft WinHTTP Services, version 5.1'.WinHttpRequest
WebserviceEndpoint: Text
ClientCertificate: Text
TheXML: Text or a DOMDocument
WebserviceEndpoint := 'https://myWebserviceEndpoint';
ClientCertificate := 'LOCAL_MACHINE\My\TheCertificatesSubjectCN';
CREATE(WinHTTPReq);
WinHTTPReq.Open('POST',WebserviceEndpoint,FALSE);
WinHTTPReq.SetClientCertificate(ClientCertificate);
WinHTTPReq.Send(TheXML);
Good luck!
Klaus
You only need to know which elements you want to use in your signature block.
Then you could use the MSXML automations and build it. You don't need .NET for that.
Check out: http://www.w3.org/TR/xmldsig-core/
well actually it is not that simple for the start, you need to be able to get access to X509Store which holds digital signatures installed on LocalMachine or CurrentUser, afterwards you need X509Certificate2 class to actually address the stored certificate rings. And when you find the correct one, you need to verify it has private key to be able to use it for signing. Then you must compute the signature and add a new xml node containing it in the correct place. Ok, this was pretty simplified described, but you need to know that it is not just assembling of xml elements to a file, but rather a bit more complicated procedure. If you know how to code all this via C/AL using correct automations (if available at all) , I'll buy you a beer