web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Encrypt message with cryptography in ax with X509Certificate2

(1) ShareShare
ReportReport
Posted on by 590
Hi All,

i have a requirement where  body of XML should be encrypt with cryptography with X509Certificates.

the dotnet code is like :-

public string SignData(string xmlBody)
{
string strResult = "";
try
{
X509Certificate2 signerCert = new X509Certificate2(keyPath, keyPass);
byte[] data = System.Text.Encoding.Default.GetBytes(xmlBody);
ContentInfo content = new ContentInfo(data);
SignedCms signed = new SignedCms(content);
CmsSigner signer = new CmsSigner(signerCert);
signer.IncludeOption = X509IncludeOption.EndCertOnly;
signed.ComputeSignature(signer);
byte[] signedBytes = signed.Encode();
string signedBytesBase64 = Convert.ToBase64String(signedBytes);
strResult = signedBytesBase64;
}

Assumption it will provided by client (keyPath, keyPass) Path and password where Cert is uploaded. Kindly let me know if assumption are right.

Could anyone can guide me how to do same in X++. Your help will be much appreciated!

Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • AdityaAxian Profile Picture
    5 on at
    [quote user="Vinesh Tandel"]
    Hi All,

    i have a requirement where  body of XML should be encrypt with cryptography with X509Certificates.

    the dotnet code is like :-

    public string SignData(string xmlBody)
    {
    string strResult = "";
    try
    {
    X509Certificate2 signerCert = new X509Certificate2(keyPath, keyPass);
    byte[] data = System.Text.Encoding.Default.GetBytes(xmlBody);
    ContentInfo content = new ContentInfo(data);
    SignedCms signed = new SignedCms(content);
    CmsSigner signer = new CmsSigner(signerCert);
    signer.IncludeOption = X509IncludeOption.EndCertOnly;
    signed.ComputeSignature(signer);
    byte[] signedBytes = signed.Encode();
    string signedBytesBase64 = Convert.ToBase64String(signedBytes);
    strResult = signedBytesBase64;
    }

    Assumption it will provided by client (keyPath, keyPass) Path and password where Cert is uploaded. Kindly let me know if assumption are right.

    Could anyone can guide me how to do same in X++. Your help will be much appreciated!
    Thanking you

    Kindly Post this and after posting kindly provide me the link for the same.
    Thanks in advance!
    [/quote]

    Kindly ignore the last line 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans