Loading ...

asp.net 3.5 X509Certificate2 Internal error...!!!!

Who is online?  0 guests and 0 members
home  »  forums   »  codeasp.net community   »  asp.net web hosting   » asp.net 3.5 X509Certificate2 Internal error...!!!!

asp.net 3.5 X509Certificate2 Internal error...!!!!

Posts under the topic: asp.net 3.5 X509Certificate2 Internal error...!!!!

Posted: 6/20/2011

Lurker 15  points  Lurker
  • Joined on: 6/20/2011
  • Posts: 3

Hi.

 

When I try to execute code below I got an error 'Internal error occurred.'

certificate = new X509Certificate2( p12FileBytes, p12FilePassword );

and when I made change  to certificate = new X509Certificate2( p12FileBytes, p12FilePassword,X509KeyStorageFlags.MachineKeySet );

I got another error 'Access Denied.'

 

How can I fix it?

 

In advance THANKS FOR HELP!

 

Regards,

Stepan.


Posted: 6/20/2011

Starter 727  points  Starter
  • Joined on: 6/6/2011
  • Posts: 74

Hi Stephan,

Posible solution to this problem is to use another constructor that takes a X509KeyStorageFlags value as a parameter:

 

X509Certificate2 cert = new X509Certificate2(certBytes, string.Empty, X509KeyStorageFlags.MachineKeySet);

 

This might solve the issue both for when running under the Network Service account as well as running under a user account with restricted access.

Best Regards,

Gjorgji Dimitrov


Posted: 6/20/2011

Lurker 15  points  Lurker
  • Joined on: 6/20/2011
  • Posts: 3

Hi Gjorgji Dimitrov.

 

When I use X509KeyStorageFlags.MachineKeySet I got an error "Access denied".

 

Regards,

Stepan.


Posted: 6/20/2011

Starter 727  points  Starter
  • Joined on: 6/6/2011
  • Posts: 74

Hi Stepan, 

This is a security permission issue. 

The problem is: User ASPNET needs change right on folder

 

D:\Document and Settings\All Users\Application Data\Microsoft\Crypto\RSA\Machine Keys


Actually, the problem is due to the different process/security model of Casinni(VS 2005 test server) or IIS based ASP.NET web application.

For IIS hosted ASP.NET applications, the worker process is running under the ASP.NET worker process account. Default one is machine\ASPNET(for IIS5) or NetworkService(for IIS6). These services account are not powerful normally.

While using the VS 2005 test server(casiini), it is actually a .net winform application, so the ASP.NET application hosted in testServer is running under the current logon user account which is always a powerful user account, so you will bypasing many security issue under this condition.

Best Regards,

Gjorgji Dimitrov


Posted: 6/20/2011

Lurker 15  points  Lurker
  • Joined on: 6/20/2011
  • Posts: 3

Hi Gjorgji Dimitrov.

I solved problem by modify ApplicationPool->identity to LocalService.

Regards,

Stepan.


Page 1 of 1 (5 items)