Re: Error instantiating RSACryptoServiceProvider

From: Ignus Fast (junk_at_no.com)
Date: 03/18/05


Date: Fri, 18 Mar 2005 09:00:39 -0600


    Sorry, it was in the original message a week ago:

    System.Security.Cryptography.CryptographicException: CryptoAPI
cryptographic service provider (CSP) for this implementation could not be
acquired.
       at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32
dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
       at
System.Security.Cryptography.RSACryptoServiceProvider..ctor(CspParameters
parameters)

    The only tips I've seen online have been:

        Add permission to the folder C:\Documents and Settings\All
Users\Application Data\Microsoft\Crypto\RSA\MachineKeys

    and add this code to initialize the RSACryptoServiceProvider:

        CspParameters cspParams = new CspParameters();
        cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
        rsacsp = new RSACryptoServiceProvider(cspParams);

    Neither of which had any affect. Any suggestions?

        Ignus

"Valery Pryamikov" <valery@harper.no> wrote in message
news:u5sk1K4KFHA.3832@TK2MSFTNGP12.phx.gbl...
> Hi Ignus,
> What error did you get? (looking through your post I didn't find any error
> description).
>
> -Valery.
> http://www.harper.no/valery
>
> "Ignus Fast" <junk@no.com> wrote in message
> news:e8SvmdzKFHA.3336@TK2MSFTNGP09.phx.gbl...
>> Ping???
>>
>> (pin dropping)
>>
>> Ignus
>>
>> "Ignus Fast" <junk@no.com> wrote in message
>> news:%235JbNxKKFHA.1812@TK2MSFTNGP15.phx.gbl...
>>> Anyone? Please, help me! :)
>>>
>>> Ignus
>>>
>>>
>>> "Ignus Fast" <junk@no.com> wrote in message
>>> news:eW6p2PpJFHA.3960@TK2MSFTNGP09.phx.gbl...
>>>> I'm trying to instantiate an RSACryptoServiceProvider in a web
>>>> service, which works fine on my local machine. But when I move the web
>>>> service out to my production server, it blows up with the following
>>>> error:
>>>>
>>>> System.Security.Cryptography.CryptographicException: CryptoAPI
>>>> cryptographic service provider (CSP) for this implementation could not
>>>> be acquired.
>>>> at System.Security.Cryptography.RSACryptoServiceProvider..ctor(Int32
>>>> dwKeySize, CspParameters parameters, Boolean useDefaultKeySize)
>>>> at
>>>> System.Security.Cryptography.RSACryptoServiceProvider..ctor(CspParameters
>>>> parameters)
>>>>
>>>>
>>>> Things I've tried:
>>>>
>>>> Using a CspProviderFlags objects to use the MachineKeyStore:
>>>>
>>>> CspParameters cspParams = new CspParameters();
>>>> cspParams.Flags = CspProviderFlags.UseMachineKeyStore;
>>>> rsacsp = new RSACryptoServiceProvider(cspParams);
>>>>
>>>> Setting the ASPNET user to have full permissions to the
>>>> MachineKeys folder.
>>>>
>>>> Originally I was just reading in the cert, then passing the
>>>> X509Certificate.PublicKey to SignedXml.CheckSignature(). This I thought
>>>> *should* have worked, since the CheckSignature method accepts an RSA,
>>>> but it always returned false (both locally and on the remote server).
>>>> So I'm exporting the 509Certificate.PublicKey data into an
>>>> RSACryptoServiceProvider, which works fine with
>>>> SignedXml.CheckSignature() locally, but always results in the above
>>>> error on the remote server.
>>>>
>>>> Any suggestions?
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>