all groups > dotnet web services enhancements > january 2005 >
You're in the

dotnet web services enhancements

group:

X509 signing only works when logged in locally


X509 signing only works when logged in locally Metrophobe
1/24/2005 10:07:20 AM
dotnet web services enhancements:
I am struggling with some web application X509 signing issues, but was
finally able to get everything working by setting the web application
impersonate value to "myuseraccount." Since the key we have to use for
signing is installed under the "myuseraccount" Personal store and not
exportable, I think I am stuck having the web app impersonate myself.

In any event, everything works fine if I leave myself logged into the
server on which the app runs. Any users accessing the box remotely can
run the page that signs a payload. After I log out, however, the
process no longer works. The Event Viewer app log seems to indicate
that the certificate for signing was not found, but why should be being
logged in affect that? Since my code is pulling from CurrentUserStore,
does that somehow use the currently logged-in user store, rather than
the store of the impersonate user?

I have played with file, folder, and certificate permissions until my
fingers bled, but it's possible I missed something. Many thanks in
advance to anyone who can help solve this one.
Re: X509 signing only works when logged in locally Dilip Krishnan
1/24/2005 12:31:17 PM
Hello Metrophobe,
Make sure IIS is running under aspnet/system account. Also give access
to the the certificate store to these users .

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

[quoted text, click to view]

Re: X509 signing only works when logged in locally Metrophobe
1/25/2005 9:25:40 AM
Thanks for your help; unfortunately, I am still stuck. I tried running
IIS under the ASP.NET account, rather than the standard
IUSR_MACHINENAME account, but still had no luck. As far as your
recommendation to give access to the certificate store, I assume that
you are speaking about the physical location ("C:\Document and
Settings\...Crypto\..."). Is there some other way (presumably through
MMC) to give access to the store from a non-physical perspective?

Even if everyone has access to the store, however, I don't see how to
specifcy the store. My certificate is in the MYUSERNAME\Personal
store, which I don't think I have access to programmatically. If I am
coding in .NET, I can access the CurrentUserStore or the
LocalMachineStore, but I don't see any way to access any kind of
"OtherUserStore." It appears that the store for MyUsername is
effectively blocked unless the ASP.NET process is running under that
account (in which case the MyUsername store becomes the
CurrentUserStore). It would seem from my testing, though, that even
then the account still has to be physically logged in before the
certificate is available.

Can anyone verify what has to happen before the CurrentUserStore for
"UserA" is available? Is it necessary to run the ASP.NET process under
that account *and* be logged in?
Re: X509 signing only works when logged in locally Sidd
1/25/2005 9:43:37 AM
Hi Metrophobe,

If ASP.NET wants to access a store to get an X509 certificate, then
typically that certificate needs to reside in the LocalMachine store, and
not the current user store. Another point to note is that when you want to
perform signing from an app hosted within ASP.NET, then it requires access
to the private key, which by default ASP.NET does not have permissions to
get, unless you do one of two things:
a) Run the ASP.NET account as SYSTEM, or Local System (if using IIS 6)
and not as Machine, or NetworkService (if using IIS 6)

b) Use the WseCertificate tool to open up that certificate (assuming it
is in the LocalMachine store), and click on the Security Tab of that tool.
There you can add either "MachineName\Users" to the list of people who
permissions, or you can add Network Service (if asp.net is running under
network service).

The above assumes that the X509 Cert is in the LocalMachine store, and not
in the CurrentUserStore or in the MyUsername\Personal store. Is there any
reason it has to be in these stores?

Thanks,

Sidd [MSFT]

[quoted text, click to view]

Re: X509 signing only works when logged in locally Metrophobe
1/25/2005 10:49:20 AM
Thanks for your help, Sidd. I believe I have a workaround now in that
I am signing with a Verisign certificate that we have loaded onto the
box. Based on my understanding and by speaking with the 3rd party,
this should work just fine. This way, of course, I can just access the
Local Machine Store and get the certificate no matter who I am logged
in as.

The reason this certificate ended up in MyUserName\Personal store is
because I received the certificate through the 3rd party's Certificate
Server via Internet Explorer while I was logged in. The cert was
automatically placed in my store, and since the private key was not
exportable, I could not export the key and still sign with it (or so it
appears). I tried explicitly giving access to the private key file and
store folders to the ASP.NET account and IUSR account to no avail.
Without the LocalMachine Store having its own private key, there was no
way to reference the original private key file.

One more question, however, to anyone with enough time to answer. I
read everywhere that for ASP.NET to access a store, the store
"typically" needs to reside in the LocalMachine store, or that the cert
"should" be in that store. No one seems to address the alternative,
however. Is accessing another user's store possible? Even if it's
not best practice, it would nice to get a definitive answer on this.
Re: X509 signing only works when logged in locally Dilip Krishnan
1/25/2005 4:19:36 PM
Hello Metrophobe,
You can set the store location via configuration... it would look like
the following
<configuration>
<microsoft.web.services2>
<security>
<x509>
storeLocation="LocalMachine|CurrentUser"
verifyTrust="true|false"
allowTestRoot="true|false"
allowRevocationUrlRetrieval="true|false"
allowUrlRetrieval="true|false" />

HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

[quoted text, click to view]

AddThis Social Bookmark Button