locked
CryptographicException "Cannot find the requested object." RRS feed

  • Question

  • I want to import a certificate in Silverlight.

    If I do this:

    X509Certificate cert = new X509Certificate(data, "pwd");

    Being data a byte[] get from a OpenFileDialog, I get this error: CryptographicException "Cannot find the requested object."

    Stack Trace:

    at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr) 
    at System.Security.Cryptography.X509Certificates.X509Utils._QueryCertBlobType(Byte[] rawData) 
    at System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[] rawData, Object password, X509KeyStorageFlags keyStorageFlags) 
    at System.Security.Cryptography.X509Certificates.X509Certificate..ctor(Byte[] rawData, String password)   
    
    
    The exact same code works in Windows forms.

    Any idea of what the problem might be? Regards.

    Thursday, November 26, 2009 10:46 AM

All replies

  • Analyzing the code with Reflector, I see that the problem is raised on this method: 

    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static extern uint _QueryCertBlobType(byte[] rawData);
     
    

     I guess that maybe it means that I cant call it from Silverlight, right?.

    Do you know another way of creating an instance of X509Certificate from a certificate that the client uploads?

    Thanks!

    Friday, November 27, 2009 6:51 AM
  • Does anyone know a way of creating an instance of X509Certificate from a certificate that the client uploads?

    Monday, December 7, 2009 8:15 AM
  • I've got the same error. The reason is that constructor waits binary certificate (DER formar), not base64 one.
    Tuesday, March 9, 2010 6:58 AM