tom_isacson
asked on
RSACryptoProvider class problem when called from within a web service
Hello,
I have a web service that creates an instance of the System.Security.Cryptograp hy.RSACryp toProvider class. When I deploy this service to an IIS6.0 server and execute it under an app pool whose identity is set to a machine specific user (which was added to the IIS_WPG group), I cannot execute the method ToXMLString(). I am getting a "The system cannot find the file specified" error.
When I point my test project's web reference to the web service in my VS 2008 solution, I have no problems. When I point my test project's web reference to the web service deployed on my local machine's IIS 5.1, again I have no problems.
I suspect a permissions issue is the most likely cause. However, I cannot determine where or why a file is attempting to be referenced when I call the ToXMLString() method - so I don't know what, if any, permissions need to be modified.
I am not persisting the keys into a KeyContainer - I simply generate a random key pair (by instantiating the RSACryptoProvider class) and then am trying to save the Public Key into a local variable. In addition, when I examine the CspKeyContainerInfo class at run time after the RSACryptoProvider object has been created, nothing seems unusual (for example, Accessible = true, Exportable = true, MachineKeyStore = false ).
Any advice would be much appreciated.
Thanks,
Tom Isacson
I have a web service that creates an instance of the System.Security.Cryptograp
When I point my test project's web reference to the web service in my VS 2008 solution, I have no problems. When I point my test project's web reference to the web service deployed on my local machine's IIS 5.1, again I have no problems.
I suspect a permissions issue is the most likely cause. However, I cannot determine where or why a file is attempting to be referenced when I call the ToXMLString() method - so I don't know what, if any, permissions need to be modified.
I am not persisting the keys into a KeyContainer - I simply generate a random key pair (by instantiating the RSACryptoProvider class) and then am trying to save the Public Key into a local variable. In addition, when I examine the CspKeyContainerInfo class at run time after the RSACryptoProvider object has been created, nothing seems unusual (for example, Accessible = true, Exportable = true, MachineKeyStore = false ).
Any advice would be much appreciated.
Thanks,
Tom Isacson
using System;
using System.Security.Cryptography;
using System.Text;
public class RSAProvider : AsymmetricBase
{
private RSACryptoServiceProvider _rsa;
private string _privatekey;
private string _publickey;
private int _keyid;
public RSAProvider()
{
Initialize();
this.GenerateKey();
}
public override void GenerateKey()
{
try
{
_rsa = new RSACryptoServiceProvider();
this._privatekey = _rsa.ToXmlString(true);
this._publickey = _rsa.ToXmlString(false);
this._keyid = -1;
}
catch (Exception e)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("Error in GenerateKey() method.");
sb.AppendLine("Inner Message:");
sb.AppendLine(e.Message);
throw new ApplicationException(sb.ToString(), e);
}
}
}
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.