Re: I want to read a .pfx and use the private key to sign a document, is that "that" bad?
- From: "John Saunders [MVP]" <john.saunders at trizetto.com>
- Date: Thu, 30 Aug 2007 16:29:29 -0400
"hubble" <max.favilli@xxxxxxxxx> wrote in message news:1188229164.237866.115640@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
I am trying to sign an xml document with a private key, reading the
key from a .pfx file. The code following.
string xml;
xml = Request.MapPath("/rsacert.pfx");
xml = HttpUtility.HtmlDecode(xml);
Trace.Write(xml);
Response.Write("<p/>");
X509Certificate2 cert = new X509Certificate2(xml, "");
RSACryptoServiceProvider crypto = cert.PrivateKey as
RSACryptoServiceProvider;
Response.Write("<p/>");
Response.Write(crypto.ToString());
If execute the code on my laptop it works (I have .net 2.0 + compact +
sdk + visual studio installed), if upload the code on one of the test
servers (windows 2003 server + .net 2.0 + compact + sdk, but no VS2005
of course) doesn't work and an exception occurs.
I get a security exception from .net "The system cannot find the file
specified." when executing the following line of code (taken from the
source code, xml is file name and it's correct):
X509Certificate2 cert = new X509Certificate2(xml, " ");
"The system cannot find the file specified." does not sound like a security exception. Why did you call it that?
This is a "file not found" exception. So, what file can't it find? The one specified in "xml"? If so, check to see if the file exists before you use it to create the certificate. Display the full path if you get an exception.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer
.
- References:
- Prev by Date: Re: Backing up and restoring encryption key
- Next by Date: Re: How to convert a SecureString into an encrypted String in a se
- Previous by thread: Re: I want to read a .pfx and use the private key to sign a document, is that "that" bad?
- Next by thread: How to convert a SecureString into an encrypted String in a secure manner?
- Index(es):
Relevant Pages
|