Announcements
Hello Team. I really stuck in a rut with next problem:
I even agree to use C/AL and dotnet variables in NAV2018 instead of AL and extensions if there is any way to generate signature (because i suppose that it's impossible to do without dotnet).
Any help will be appreciate.
*This post is locked for comments
A question.
And how or where are you setting the certificate and password to sign the document?
Thank you ever so much
CSPParams DotNet System.Security.Cryptography.CspParameters.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
RSA DotNet System.Security.Cryptography.RSACryptoServiceProvider.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XmlDocument DotNet System.Xml.XmlDocument.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
XmlTextReader DotNet System.Xml.XmlTextReader.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
SignedXml DotNet System.Security.Cryptography.Xml.SignedXml.'System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Reference DotNet System.Security.Cryptography.Xml.Reference.'System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Env DotNet System.Security.Cryptography.Xml.XmlDsigEnvelopedSignatureTransform.'System.Security, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
XmlDigSignature DotNet System.Xml.XmlElement.'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
Can you list variable types?
Hi Andrey, I've checked and my addin performs criptography with signed certificate (with RSACryptoServiceProvider).
I think this is not exactly what you was searching. Nice to see that you've solved your problem.
And the answer is:
CSPParams := CSPParams.CspParameters(1, 'Microsoft Base Cryptographic Provider v1.0', 'DevRootCA'); RSA := RSA.RSACryptoServiceProvider(CSPParams); XmlDocument := XmlDocument.XmlDocument; XmlDocument.PreserveWhitespace(FALSE); XmlDocument.Load(XmlTextReader.XmlTextReader('C:\Temp\Data.xml')); SignedXml := SignedXml.SignedXml(XmlDocument); SignedXml.SigningKey := RSA; Reference := Reference.Reference; Reference.Uri := ''; Env := Env.XmlDsigEnvelopedSignatureTransform; Reference.AddTransform(Env); SignedXml.AddReference(Reference); SignedXml.ComputeSignature; XmlDigSignature := SignedXml.GetXml; MESSAGE(XmlDigSignature.InnerXml);
So now i have next code:
CSPParams := CSPParams.CspParameters; // Here is main issue -> //CSPParams.KeyContainerName = 'DevRootCA'; //<- RSA := RSA.RSACryptoServiceProvider(CSPParams); XmlDocument := XmlDocument.XmlDocument; XmlDocument.PreserveWhitespace(FALSE); XmlDocument.Load(XmlTextReader.XmlTextReader('C:\Temp\Data.xml')); SignedXml := SignedXml.SignedXml(XmlDocument); SignedXml.SigningKey(RSA); Reference := Reference.Reference; Reference.Uri := ''; Env := Env.XmlDsigEnvelopedSignatureTransform; Reference.AddTransform(Env); SignedXml.AddReference(Reference); SignedXml.ComputeSignature; XmlDigSignature := SignedXml.GetXml; MESSAGE(XmlDigSignature.InnerXml);
I Have dotnet variable CSPParams which I took from mscorlib:
System.Security.Cryptography.CspParameters.'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
And the problem is that it doesn't have .KeyContainerName field. So I can't set it and get the key. As I understood - I just need to set SSL certificate name there? Has anyone encountered a similar problem?
I'm moving through next instruction:
docs.microsoft.com/.../how-to-sign-xml-documents-with-digital-signatures
Stefano Demiliani have you had a chance to look for code? I'll be very appreciate.
It'll be great!
Yes if you want I can share it. I've only to return at my office for doing that :)
I found System.Security.Cryptography.Xml
Thanks for inspiring me!
André Arnaud de Cal...
294,095
Super User 2025 Season 1
Martin Dráb
232,866
Most Valuable Professional
nmaenpaa
101,158
Moderator