[help] The request for security token could not be satisfied because authentication failed.[help] The request for security token could not be satisfied because authentication failed.
Old forum URL: forums.lhotka.net/forums/t/7474.aspx
wapt49 posted on Tuesday, August 18, 2009
Hallo all =),
Im newbie by security in wcf..
I got exception : The request for security token could not be satisfied because authentication failed.
Hier ist code which running in server :
static void Main(string[] args)
{
Uri address = new Uri("http://localhost:8080/Hello");
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Message;
binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
Type contract = typeof(Model.IHello);
using (ServiceHost host = new ServiceHost(typeof(HelloService)))
{
try
{
host.AddServiceEndpoint(contract, binding, address);
host.Credentials.ServiceCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindBySubjectName,"localhost");
host.Open();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
Console.WriteLine("Return um Service zu beenden");
Console.ReadLine();
}
}
and hier ist code for client:
static void Main(string[] args)
{
EndpointAddress address = new EndpointAddress("http://localhost:8080/Hello");
WSHttpBinding binding = new WSHttpBinding();
binding.Security.Mode = SecurityMode.Message;
binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate;
System.ServiceModel.ChannelFactory<IHello> cf = new ChannelFactory<IHello>(binding,address);
cf.Credentials.ClientCertificate.SetCertificate(
StoreLocation.CurrentUser,
StoreName.My,
X509FindType.FindBySubjectName,
"WCFUser");
cf.Credentials.ServiceCertificate.SetDefaultCertificate(
StoreLocation.CurrentUser,
StoreName.My,
X509FindType.FindBySubjectName,
"localhost");
IHello proxy = cf.CreateChannel();
string msg = proxy.SayHello("Putra");
Console.WriteLine(msg);
Console.ReadLine();
}
Server running, but when i try to start the client i get exception:
The request for security token could not be satisfied because authentication failed.
anyone can help to solve my problem??
Many many thanks
wapt49 replied on Thursday, August 20, 2009
help please :(
Copyright (c) Marimer LLC