How to add digital signature to xml file?
arcull
Member Posts: 191
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
-
I found Dan's Blog helpful: http://www.danlance.co.uk/index.cfm/201 ... ation-Wind
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!
Klaus0 -
Thank you very much Klaus for the info. But unfortunately this approach requires to use a web service (remote or local), is it possible to avoid this requirement? If you had similar situation, would you be so kind to explain a bit more in detail how you solved this issue, thanks again.0
-
I guess I'll have to do the signature part in C#. Thanks anyway for your help.0
-
Hi!
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/0 -
Hi!
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
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 328 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions