Skip to main content

Notifications

Announcements

No record found.

Small and medium business | Business Central, N...
Suggested answer

SignXmlText

(1) ShareShare
ReportReport
Posted on by 27
I'm trying to sign XML through CU 6227 /Signed XML Mgt./ with the function SignXmlText. This procedure requires a private key which I got from Isolate Certificate using X509Certificate2.GetCertificatePrivateKey. This procedure returns my private key in XML string. I'm converting this to base64 and sending it as a parameter to SignedXMLMgt.SignXmlText(myxml, privatekey), but I'm getting the error /A call to System.Security.Cryptography.RSACryptoServiceProvider.ImportCspBlob failed with this message: Bad Version of provider./

Below is the code how i managed to get certificate and private key. I think i used the wrong method to get private key but this is the only way i could do it.
 
if IsolatedCert.Get('CERT0000000011') then begin
        cert64 := CertificateMgt.GetCertAsBase64String(IsolatedCert);
        if X509Certificate2.HasPrivateKey(cert64, password) then
             privatekey := X509Certificate2.GetCertificatePrivateKey(cert64, password);
end
 
signedxml := SignXmlMgmt.SignXmlText(xml, Base64Convert.ToBase64(privatekey));

As per the error message, it seems I need to export the CSP blob and send it as base64 to the SignXmlText() procedure. The question is how (bc this not possible from AL) or is there any other method i can do it.
  • asa Profile Picture
    asa 27 on at
    SignXmlText
    BC23
  • Suggested answer
    tanya07 Profile Picture
    tanya07 1,548 on at
    SignXmlText
    Hi,
    which is the NAV/BC version are you working on ?
    BR,
    Tanya

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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,642 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,371 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans