Invalid Algorithm when creating Xades signature

Oct 18, 2013 at 12:41 PM

I'm using this Xades library when communicating with MyCarenet.

I've downloaded the DLL, but the first issue that I encountered, was that there was apparently a dll missing. (Security.Cryptography.dll) I've downloaded that dll from codeplex and referenced it in my application. (When I download the source, I do not see a reference to Security.Cryptography, however, in the manifest of the downloaded IM.Xades.dll, there exists a reference to Security.Cryptography).

However, when I try to create a Xades-T signature, a Cryptographic-exception is thrown which says 'Invalid algorithm specified'.
I'm running this on a Windows 8 machine. Any idea what might go wrong ?
Oct 18, 2013 at 1:48 PM
I've changed the code of the CreateXadesBas method a bit, based on a post on stackoverflow ...

Instead of using the PrivateKey of the X509Certificate2 instance that is passed via the constructor as the signing-key, I use an RSACryptoServiceProvider instance that I initialize with the private key of the X509Certificate:
            CspParameters cspParams = new CspParameters (24);
            cspParams.KeyContainerName = "XML_DISG_RSA_KEY";
            RSACryptoServiceProvider key = new RSACryptoServiceProvider (cspParams);
            key.FromXmlString (certificate.PrivateKey.ToXmlString (true)); 

            //Set the signingg key
            signedXml.SigningKey = key;
Although I believe that this is not the way to go, creating the XadesBes signature now works.

However, in order to create a XadesT, the ehealth timestamping service needs to be contacted, and now they return me a (generic) error message. (Error occured - contact eHealth)
May 12, 2014 at 12:08 PM

I encounter the same problem as you.

I adapted the code Xades library as you say and now I encounter the following error:

"Key not valid for use in specified state".

Did you know go further in your implementation?

Thank you in advance.

Good to you.

Damien Detrain