all groups > dotnet security > november 2007 >
You're in the

dotnet security

group:

httpwebrequest failure with .net service


httpwebrequest failure with .net service chaz
10/31/2007 10:36:01 AM
dotnet security:
running Hi,
I have a .net 2.0 service that periodically needs to access a web site on
the same 2003 server machine that is configured to use https .
The only way I can get this working is to run the service with the
administrator login , no other account (system, local service, or account
that is a member of the administrators group ).

the failure is 2148074254 - No credentials are available in the security
package
and the message is
The underlying connection was closed: Could not establish trust
relationship for the SSL/TLS secure channel

any ideas on how to proceed ?

thanks,
chaz



Re: httpwebrequest failure with .net service Joe Kaplan
10/31/2007 1:33:41 PM
Do you know if SSL client certificate authentication is being performed? It
may be the case that the server is requesting client cert auth and only the
admin account on your box has permissions to access the private key for the
client cert that is being used (which may actually be the server's own SSL
cert since it is the same box).

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
[quoted text, click to view]

Re: httpwebrequest failure with .net service Henning Krause [MVP - Exchange]
10/31/2007 9:01:18 PM
Hell,

if the root certificate of your SSL certificate is not in the trusted root
certificate store, you get this error.

The best way to deal with this is to add it to that store.If you can't do
this for whatever reason, you can disable the check using this line of code,
which you should rould once during the start of your program:

ServicePointManager.ServerCertificateValidationCallback = delegate(object
sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors
sslPolicyErrors) { return true; };

Kind regards,
Henning

[quoted text, click to view]
Re: httpwebrequest failure with .net service chaz
11/2/2007 3:24:00 AM
Hi,
Thanks to you both of you for the valuble feedback.
I've implemented your work-around Henning and this works well with "ignore
certificates" or "accept certificates" . Eventualy I will want to figure out
the issue but for now I can move on to the next issue which is - "require
certificates" .
Joe started me thinking that this may just work if the windows service
could use the web-sites server certificate as a client certificate when
making the HTTPS request . Do either of you have suggestions regarding this
issue . Are client certificates for services/processes ( or machines for
that matter) routinely generated ? If so how would one map theses ?

Any pointers , ideas would be appreciated .
thanks,
chaz



[quoted text, click to view]
Re: httpwebrequest failure with .net service Joe Kaplan
11/2/2007 9:58:39 AM
So, it sounds like you ARE trying to do client certificate authentication if
you are planning to require client certificates. As such, the key to this
is to make sure you have an appropriate client certificate available for
your client and make sure the identity that is running your code has
permissions to access the private key for that certificate. I think that
was the original problem you were having, as the admin account had access to
the private key for the cert you were using but no other account did (which
is normal).

Joe K.

--
Joe Kaplan-MS MVP Directory Services Programming
Co-author of "The .NET Developer's Guide to Directory Services Programming"
http://www.directoryprogramming.net
--
[quoted text, click to view]

AddThis Social Bookmark Button