HighTechTalks DotNet Forums  

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

Dotnet Security microsoft.public.dotnet.security


Discuss I want to read a .pfx and use the private key to sign a document, is that "that" bad? in the Dotnet Security forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
hubble
 
Posts: n/a

Default I want to read a .pfx and use the private key to sign a document, is that "that" bad? - 08-27-2007 , 11:39 AM






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

I think it's was they talk about here:
http://support.microsoft.com/kb/915980

As they say the hotfix need to be requested to the customer support, I
will on monday, but they also add if your application run on "Full
trust" it shouldn't happen. My application is running on "Full Trust".

Has anyone got the hotfix? Does it really fix the problem?

I generated the certificate using makecert as explained here:
http://code.google.com/support/bin/a...64#DotNetTools

Since I understood (reading articles here and there on the web) that
the problem is related to certificates not installed in the
certificates store of windows 2003 server. I right clicked on the .pfx
file and choose "import", I can see it in the certificates store, but
still doesn't work, same exception, nothing changed.

I am lost... I hate the world... Everyone is evil... Programming
sucks... I hate certificates... I want a world free of them...

Please HELP!


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.