Skip to main content

Notifications

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

  • Mohana Yadav Profile Picture
    60,209 Super User 2025 Season 1 on at
    RE: Using "Cryptography Management"

    Did you guys find a solution for the same?

  • Joriek Profile Picture
    15 on at
    RE: Using "Cryptography Management"

    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

  • Gijs1985 Profile Picture
    5 on at
    RE: Using "Cryptography Management"

    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
    RE: Using "Cryptography Management"

    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
    RE: Using "Cryptography Management"

    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
    RE: Using "Cryptography Management"

    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
    RE: Using "Cryptography Management"

    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,

  • imkarthikeyan Profile Picture
    67 on at
    RE: Using "Cryptography Management"

    Did u find any solution??

  • Suggested answer
    Marco Mels Profile Picture
    on at
    RE: Using "Cryptography Management"

    Hi,

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

    Thanks.

  • Gijs1985 Profile Picture
    5 on at
    RE: Using "Cryptography Management"

    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,

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,069 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,858 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans