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 :
Small and medium business | Business Central, N...
Answered

SignXmlText

(3) ShareShare
ReportReport
Posted on by 66
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.
I have the same question (0)
  • Suggested answer
    tanya07 Profile Picture
    1,638 on at
    Hi,
    which is the NAV/BC version are you working on ?
    BR,
    Tanya
  • asa Profile Picture
    66 on at
    BC23
  • Verified answer
    asa Profile Picture
    66 on at
    I used SignatureKey: Codeunit "Signature Key", to store my key, as i mentioned above my approach to retrieving the private key from the certificate was wrong.

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 > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,664

#2
YUN ZHU Profile Picture

YUN ZHU 960 Super User 2025 Season 2

#3
Jainam M. Kothari Profile Picture

Jainam M. Kothari 773 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans