Notifications
Announcements
public static str encryptWithPublicKey(str jsonPayload, str publicKeyXml) { System.Exception netException; System.Security.Cryptography.RSACryptoServiceProvider rsa; System.Text.Encoding encoding; System.Byte[] payloadBytes; System.Byte[] encryptedBytes; str base64Encrypted; try { rsa = new System.Security.Cryptography.RSACryptoServiceProvider(); rsa.FromXmlString(publicKeyXml); encoding = System.Text.Encoding::get_UTF8(); payloadBytes = encoding.GetBytes(jsonPayload); encryptedBytes = rsa.Encrypt(payloadBytes, false); base64Encrypted = System.Convert::ToBase64String(encryptedBytes); } catch(netException) { error(strFmt("Encryption failed: %1", netException.ToString())); return ""; } return base64Encrypted; }
Hello,
I am implementing RSA encryption of JSON data in D365FO using a public key extracted from a .pem file.
.pem
The solution works correctly in UAT and Performance, but fails in Production with the following error during batch execution:
Unable to find manual secret value The given key was not present in the dictionary Batch task failed: KeyNotFoundException
Initially, the public key was read from Azure Key Vault. To rule this out, I moved the key to a table memo field, but the same error occurs in Production only.
Since the code and configuration are identical across environments, I suspect a production-specific issue related to encryption handling, batch execution context or security (not aware if their is )
Any guidance on resolving this would be appreciated.
Regards, Ayushaman
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Abhilash Warrier 843 Super User 2025 Season 2
André Arnaud de Cal... 467 Super User 2025 Season 2
Martin Dráb 338 Most Valuable Professional