Skip to main content
Business Central forum
Suggested answer

SignXmlText

editSubscribe (1) ShareShare
ReportReport
Posted on by 18
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.
Attachments
  • asa Profile Picture
    asa 18 on at
    SignXmlText
    BC23
  • Suggested answer
    tanya07 Profile Picture
    tanya07 1,523 on at
    SignXmlText
    Hi,
    which is the NAV/BC version are you working on ?
    BR,
    Tanya

Helpful resources

Quick Links

What Motivates a Super User?

We know many of you visit the Dynamics 365 Community and Power Platform…

Demystifying Copilot with Georg Glantschnig…

Industry experts answer burning questions directly from our amazing Community…

Setting Up Knowledge Sources for Copilot…

Look at how configuring a comprehensive knowledge base is crucial…

Leaderboard

#1
Andre Arnaud de Calavon Profile Picture

Andre Arnaud de Cal... 283,080 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 222,601 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,138

Featured topics

Product updates

Dynamics 365 release plans