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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Using "Cryptography Management"

(0) ShareShare
ReportReport
Posted on by 5

Hi community,

I am building an extension in Business Central and I need to apply a HTTP signature to my API calls.

At this moment I am using the function SignData in codeunit 1266 "Cryptography Management", because I need to sign my data with algorithm sha256 and by using my private key file.

When I use this function however, I receive the following error message.

Error:

A call to System.Security.Cryptography.RSACryptoServiceProvider.FromXmlString failed with this message: Invalid syntax on line 1.

Code:

        TempBlob.CreateOutStream(SignatureOutStream);
        CryptographyMgt.SignData(SigningString, PrivateKeyFile, HashAlgorithmType::SHA256, SignatureOutStream);

Does anyone have an idea what could be the problem?

Thanks a lot!

Kind regards,

Gijs

I have the same question (0)
  • Marco Mels Profile Picture
    Microsoft Employee on at

    Hello,

    Maybe this new blog posting may help:
    https://cloudblogs.microsoft.com/dynamics365/it/2019/09/04/cryptography-management-in-dynamics-365-business-central/

    Thanks.

  • Gijs1985 Profile Picture
    5 on at

    Hi Marco,

    Unfortunately I already came across this blog posting and this didn't help me.

    I contacted Microsoft for this issue and I will keep this post up-to-date.

    Kind regards,

  • Suggested answer
    Marco Mels Profile Picture
    Microsoft Employee on at

    Hi,

    If there was an outcome, then maybe you can share it with the community?

    Thanks.

  • imkarthikeyan Profile Picture
    67 on at

    Did u find any solution??

  • Gijs1985 Profile Picture
    5 on at

    You can only use this function if the private key file is a XML file.

    In this case the private key file was a PEM file, so I had to transform the PEM file to a XML file to be able to use this function.

    Kind regards,

  • Joriek Profile Picture
    15 on at

    Hey Gijs, how did you convert this PEM file to an XML? Can you do this only using AL code or did you need any 3th party tools?

  • Gijs1985 Profile Picture
    5 on at

    Hi Joriek,

    There is no function available in AL for this at the moment, so I had to look for a third party tool to transform PEM to XML.

    After doing some research I came across a .net project that was able to do this.

    If I remember correct, it was this one: github.com/.../pem2xml

    Kind regards,

  • Joriek Profile Picture
    15 on at

    Thank you for your respons, I guess the correct method is to add my pem file to the exe directory, use the cmd to execute the .exe file and use the generated XML in my BC. Or did you use another method?

  • Gijs1985 Profile Picture
    5 on at

    Not really sure that this was exactly the project that I used, but your approach looks correct to me.

    In any case you should be able to import the generated XML file in BC and use it in cryptography mgt.

  • Joriek Profile Picture
    15 on at

    It seems like the cryptography mgt accepted the key but the webservice that I'm contacting is still returning errors over my signature.

    So many unknown variables on this, but I won't stop looking.

    Thank you very much for your response!

    Kind regards,

    Joriek

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,344 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,742 Super User 2026 Season 1

#3
AndrewThomas81 Profile Picture

AndrewThomas81 1,231

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans