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...
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

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,028 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 1,366 Super User 2026 Season 1

#3
Grigorios Mavrogeorgis Profile Picture

Grigorios Mavrogeorgis 1,175 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans