Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Security / August 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hubble - 27 Aug 2007 16:39 GMT
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/answer.py?answer=71864#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!
hubble - 29 Aug 2007 20:11 GMT
Really no one did that in the past?
John Saunders [MVP] - 30 Aug 2007 21:29 GMT
>I am trying to sign an xml document with a private key, reading the
> key from a .pfx file. The code following.
[quoted text clipped - 21 lines]
> 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.
Signature

--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.