16
Views
0
Comments
[CryptoAPI] {"Errors":["Bad Data.\r\n"],"StatusCode":500}
cryptoapi
Service icon
Forge asset by João Barata
Application Type
Service

I want use RSA_Sign to create a signiture.

I created a Rest-Api SignMessage that should do the work.


The variable request is assigned to : BinaryDataToText(Resources.privatekey_pem.Content)

The RSA private key is added as a resource

This contents of this PEM file looks like this:

The private key is a RSA key:

openssl rsa -in private-key.pem -check

RSA key ok

writing RSA key

-----BEGIN PRIVATE KEY-----

....

-----END PRIVATE KEY-----

When I call the rest-API in my browser I get this as response:

{"Errors":["Bad Data.\r\n"],"StatusCode":500}

In ServiceCenter General Log I only see the first LogMessage and in the Errorlog I see this:

Bad Data.
   at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
   at System.Security.Cryptography.Utils._ImportKey(SafeProvHandle hCSP, Int32 keyNumber, CspProviderFlags flags, Object cspObject, SafeKeyHandle& hKey)
   at System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters)
   at ardo.Crypto.CryptoBackend.<>c__DisplayClass34_0.<GetRSAProviderFromPem>b__0(RSACryptoServiceProvider rcsp, RsaKeyParameters rkp)
   at OutSystems.NssCryptoAPI.CssCryptoAPI.MssRSA_PrivateKeyFromPEM(String ssPEM, String& ssPrivateKey)
   at ssSandBoxRaymond_Reactive.RssExtensionCryptoAPI.MssRSA_PrivateKeyFromPEM(HeContext heContext, String inParamPEM, String& outParamPrivateKey) 


What am I doing wrong?

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.