Link to home
Create AccountLog in
Avatar of Alan_Mc
Alan_Mc

asked on

Error when creating X509Certificate

Hi,

I'm trying to create an X509 object for an SSL Client Certificate I'm using to POST something, and I get this error..

"Server Error in '/MyWeb' Application.
Access is denied.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Security.Cryptography.CryptographicException: Access is denied."

The source code error appears in the line:

Dim clientCert As X509Certificate = X509Certificate.CreateFromCertFile((Server.MapPath("Files/myCert.cer")))


The web is hosted on the localhost (so when I debug I go to https://localhost/myweb"), and I have admin privileges.. As far as I know, the certificate is installed in the mmc, and if I open the console I can see it under "Certificates(Local Computer)->Personal->Certificates".

Can someone please help?
Many thanks
Avatar of Paranormastic
Paranormastic
Flag of United States of America image

Where are you trying to install the client cert to?  Is it being written to the hard drive or to a smartcard?  If it is to a smartcard, check to make sure that you do not have the archive box checked in the cert template as that tends to cause issues since the token will not release the private key in order for it to be exported.
You can also make sure that you have permissions on the cert template, regardless of your administrator priviledges, although I believe that should be giving you a different and more understandable error.
Avatar of Alan_Mc
Alan_Mc

ASKER

Hi Paranormastic.. What do you mean where am I trying to install it?
What I did from my computer was going to the mmc (windows XP machine) and install it there (what I explained in the first post). That is in my computer, in my windows operating system, so I guess the answer to your question is "to the hard drive"? I am not 100% sure tho, since I don't understand exactly what you mean.
Could you please be more specific as to what you mean with "you have permissions on the cert template"? As well as any other idea you might have on the issue pelase..

Many thanks!
ASKER CERTIFIED SOLUTION
Avatar of Paranormastic
Paranormastic
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
(note on last comment - 'issues on the server' can related to your workstation if that is where the code is running from)