Using RSA from ASP.NET

From: Kevin Burton (rkevinburton@charter.net)
Date: 02/12/03


From: "Kevin Burton" <rkevinburton@charter.net>
Date: Wed, 12 Feb 2003 12:38:50 -0800


I am trying to use SignedXml from an ASP.NET web page but
it seems to throw an exception. I can build a simple
Windows Form that calls RSA.Create and I don't have any
problem. But when I put virtually the identical code in an
ASP.NET application I get an exception at RSA.Create.
The details are included below. Any idea how I work around
this problem. I need to be able to sign and/or encrypt
data returned from this ASP.NET application but there is
some permission problem that I don't understand.

Thank you in advance for your help.

Kevin Burton
rkevinburton@charter.net

Server Error in '/AMPOCScan' Application.
-----------------------------------------------------------
---------------------

CryptoAPI cryptographic service provider (CSP) for this
implementation could not be acquired.
Description: An unhandled exception occurred during the
execution of the current web request. Please review the
stack trace for more information about the error and where
it originated in the code.

Exception Details:
System.Security.Cryptography.CryptographicException:
CryptoAPI cryptographic service provider (CSP) for this
implementation could not be acquired.

Source Error:

Line 93: signedXml.AddReference
(reference);
Line 94:
Line 95: RSA rsaKey = RSA.Create();
Line 96: signedXml.SigningKey =
rsaKey;
Line 97: KeyInfo keyInfo = new
KeyInfo();
 

Source File: c:\projects\baxter\ampocscan\ampocscan.cs
Line: 95

Stack Trace:

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

[TargetInvocationException: Exception has been thrown by
the target of an invocation.]
   System.Reflection.RuntimeConstructorInfo.InternalInvoke
(BindingFlags invokeAttr, Binder binder, Object[]
parameters, CultureInfo culture, Boolean isBinderDefault)
+0
   System.Reflection.RuntimeConstructorInfo.Invoke
(BindingFlags invokeAttr, Binder binder, Object[]
parameters, CultureInfo culture) +509
   System.Security.Cryptography.CryptoConfig.CreateFromName
(String name, Object[] args) +418
   System.Security.Cryptography.RSA.Create(String algName)
+7
   System.Security.Cryptography.RSA.Create() +13
   Baxter.Stargate.AMPOCScan.GeneratePumpInfo() in
c:\projects\baxter\ampocscan\ampocscan.cs:95
   
Baxter.Stargate.AMPOCScan.Application_AcquireRequestState
(Object source, EventArgs e) in
c:\projects\baxter\ampocscan\ampocscan.cs:138
   System.Web.SyncEventExecutionStep.Execute() +60
   System.Web.HttpApplication.ExecuteStep(IExecutionStep
step, Boolean& completedSynchronously) +87

 

-----------------------------------------------------------
---------------------
Version Information: Microsoft .NET Framework
Version:1.0.3705.288; ASP.NET Version:1.0.3705.288



Relevant Pages

  • Failure decoding embedded permission set object After .Net service pack install
    ... W2k web server I get the above error on all applications. ... Exception Details: System.Security.SecurityException: Failure decoding ... Binder binder, Objectargs, CultureInfo culture, Object ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: problems with encoding for different locales
    ... I only get the exception below on certain Spanish locales.. ... invokeAttr, Binder binder, Objectparameters, CultureInfo culture) ... at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, ...
    (microsoft.public.dotnet.xml)
  • ASP.NET 2.0 with ADAM - problem
    ... An unhandled exception occurred during the execution of the ... System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, ... modifiers, CultureInfo culture, StringnamedParams) +2501232 ... _Default.Page_Load(Object sender, EventArgs e) +71 ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Exception has been thrown by the target of invocation exception
    ... For some reason when application tries to load signed XML into the ... Exception has been thrown by the target of an invocation. ... Binder binder, Objectparameters, CultureInfo culture) at ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Exception has been thrown by the target of an invocation
    ... For some reason when application tries to load signed XML into the SignedXml ... Exception has been thrown by the target of an invocation. ... Binder binder, Objectparameters, CultureInfo culture) at ...
    (microsoft.public.dotnet.security)