search
Twitter Rss Feeds
MicrosoftArticlesForumsGroups
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml/Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsGroups
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsGroups
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsGroups
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsGroups
Microsoft Excel
Microsoft Word
Microsoft Powerpoint
Publisher
Money

Operating SystemsArticlesForumsGroups
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsGroups
Share Point
BizTalk
Site Server
Exhange Server
IIS
Transaction Server

Graphic DesignArticlesForumsGroups
Macromedia Flash
Adobe PhotoShop
Microsoft Expression

OtherArticlesForumsGroups
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Reviews
Search Engines
Resumes

 

Previous Thread:   Security issue running unmanaged code in a win form ctrl hosted in

3/29/2006 5:37:57 AM    Strange problem with X509Certificate2 on Windows 2003
Hi,  
  
I am loading a private .pfx key using the X509Certificate2 class by the  
  
following line  
  
X509Certificate2 x509 = new X509Certificate2(PrivateKeyFile,  
  
PrivateKeyPassword);  
  
where PrivateKeyFile and PrivateKeyPassword are strings.  
  
This perfectly works on my computer with windows XP home and Visual Web  
  
Developer Express.  
  
But, when I upload this code to the production Windows Server 2003  
  
Standart edition, the code throws the exception  
  
System.Security.Cryptography.CryptographicException: The system cannot  
  
find the file specified.  
  
I am sure the file path PrivateKeyFile is correct, though I try to use  
  
an alternative where I load the private key into a byte array and then  
  
calling the X509Certificate2 directly on this array.  
  
byte[] klic = File.ReadAllBytes(PrivateKeyFile);  
  
X509Certificate2 x509 = new X509Certificate2(klic, PrivateKeyPassword);  
  
The key file is read correctly, but the certificate construcotr throws  
  
the same exception  
  
System.Security.Cryptography.CryptographicException: The system cannot  
  
find the file specified.  
  
System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32  
  
hr) +33  
  
System.Security.Cryptography.X509Certificates.X509Utils._LoadCertFromBlob(Byte[]  
  
rawData, IntPtr password, UInt32 dwFlags, Boolean persistKeySet,  
  
SafeCertContextHandle& pCertCtx) +0  
  
System.Security.Cryptography.X509Certificates.X509Certificate.LoadCertificateFromBlob(Byte[]  
  
rawData, Object password, X509KeyStorageFlags keyStorageFlags) +194  
  
System.Security.Cryptography.X509Certificates.X509Certificate2..ctor(Byte[]  
  
rawData, String password) +134  
  
Muzo.Sign(String text) in  
  
d:\weby\kvetiny-kytice.cz\3dplatba\App_Code\Muzo.cs:71  
  
Muzo.CreateOrder(Page page, String orderNumber, String amount,  
  
String depositFlag, String merOrderNum, String url, String description,  
  
String md) in d:\weby\kvetiny-kytice.cz\3dplatba\App_Code\Muzo.cs:42  
  
user_redirect_muzo.Page_Load(Object sender, EventArgs e) in  
  
d:\weby\kvetiny-kytice.cz\3dplatba\user-redirect-muzo.aspx.cs:16  
  
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object  
  
o, Object t, EventArgs e) +15  
  
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object  
  
sender, EventArgs e) +34  
  
System.Web.UI.Control.OnLoad(EventArgs e) +99  
  
System.Web.UI.Control.LoadRecursive() +47  
  
System.Web.UI.Page.ProcessRequestMain(Boolean  
  
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  
  
+1061  
  
It is strange because there is no file to open in this case.  
  
The version of NET is 2.0.50727 on both computers.  
  
Any suggestions?  
  
Mirek.

3/31/2006 7:06:52 AM    Re: Strange problem with X509Certificate2 on Windows 2003
We made some new experiments regarding this problem, and found out some  
  
new and very strange facts.  
  
When the website runs under some user account and this user is logged  
  
in through terminal service, the X509Certificate2 works well.  
  
But when this user logs out, it stops working even if the website  
  
webserver still runs under this user.  
  
A temporary solution is possible by running an arbitrary program  
  
(calc.exe) by the same user as the website webserver runs under. This  
  
program is started by the scheduler at the system startup.  
  
It seems to me like a bug in Windows 2003. Or am I wrong?  
  
Mirek.

3/31/2006 10:22:11 AM    Re: Strange problem with X509Certificate2 on Windows 2003
yes it sounds like an acl issue. Don't have WinServer 2003 so can't check.  
  
- Mitch  
  
<mira@utia.cas.cz> wrote in message news:1143817612.862493.161990@i40g2000cwc.googlegroups.com...

4/3/2006 2:56:24 AM    Re: Strange problem with X509Certificate2 on Windows 2003
If this is a bug, is there some email adress at Microsoft to report it?  
  
Mirek.


Pete's Blog   |    Pete's Resume   |    Robbe's Blog   |    Robbe's Resume   |    Archive #2   |    Archive #3   |    Dotnetslackers   |    XmlPitStop   |    Advertise   |   Contact Us   |   Privacy   |   Copyright (c) 2000 - 2009 eggheadcafe.com  All rights reserved.