Re: I want to read a .pfx and use the private key to sign a document, is that "that" bad?

"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);


X509Certificate2 cert = new X509Certificate2(xml, "");
RSACryptoServiceProvider crypto = cert.PrivateKey as


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


Relevant Pages

  • Re: problem with XML DOM load command
    ... with invalid XML and I'm getting suspicious that something in a QFE ... has busted MSXML and its exception processing. ... 2003 Microsoft Corporation. ... >> So this exception is on your main thread where you're doing the load. ...
  • XML Verarbeitung
    ... Ich möchte eine XML Datei in ein DataSet einlesen und in einem DataGrid ... An unhandled exception occurred during the execution of the ... Please review the stack trace for more information about ...
  • Re: writeXML(fullFilePath) DOESNT Write
    ... I also wonder if you get an exception on attempt to load saved file... ... > The following hardware and drivers are not supported in the Emulator: ... > File system drivers, which include file allocation table, compact ... XML into the dataset from the path noted in the code I've provided (using ...
  • Client Error When Consuming Web Method
    ... write directly to the XMLDocument. ... (Originally the XML was passed as a string. ... Server was unable to read ... First, is this actually a server side exception, or will the proxy code ...
  • Re: Can I change to field type in an XML schema automatically?
    ... You should catch this exception and print out error messages from error ... >>>I have built an XML file using the DataSet.writeXML method and it creates ... >>> Now the issue I have is getting the Double into a sqlce database. ...