[quoted text, click to view] On Mar 29, 1:13 pm, "Tiago Halm" <th...@nospam.hotmail.com> wrote:
> Let us know more details, in particular the binding (basicHttpBinding,
> wsHttpBinding, netTcpBinding, etc...) and its attributes. We need to know
> where the security check takes place (transport or message) and how the
> server/client authenticate.
I'm using .Transport security.
Both the client and server use the same classes for WCF.
A secure Host/Receiver is created as follows:
------------------------------------------------------------------
private static int MAX_RECEIVED_MESSAGE_SIZE = 128 * 1024; // 128KB
public static ServiceHost MakeServiceHost(IPost creator, string
endpoint)
{
receiver = new ServiceHost(...);
... .PostObj = creator; // the creator contains PostMessage()
Uri serviceUri = new Uri(endpoint);
BasicHttpBinding httpBinding = new BasicHttpBinding();
XmlDictionaryReaderQuotas quota = new XmlDictionaryReaderQuotas();
quota.MaxStringContentLength = MAX_RECEIVED_MESSAGE_SIZE;
httpBinding.ReaderQuotas = quota;
httpBinding.MaxBufferSize = MAX_RECEIVED_MESSAGE_SIZE;
httpBinding.MaxReceivedMessageSize = MAX_RECEIVED_MESSAGE_SIZE;
if (endpoint.Contains("https://"))
{
httpBinding.Security.Mode = BasicHttpSecurityMode.Transport;
httpBinding.Security.Transport.ClientCredentialType =
HttpClientCredentialType.Certificate;
receiver.AddServiceEndpoint(...);
return receiver;
}
.... // non-secure endpoint code not shown
}
A secure Sender is created as follows:
--------------------------------------------------------
public static ... MakeSender(string endpoint, string
SSLCertThumbprint)
{
if (endpoint.Contains("https://"))
{
BasicHttpBinding secureBinding = new BasicHttpBinding();
secureBinding.Security.Mode = BasicHttpSecurityMode.Transport;
secureBinding.Security.Transport.ClientCredentialType =
HttpClientCredentialType.Certificate;
EndpointAddress secureEndpointAddress = new
EndpointAddress(endpoint);
sender = new ... (secureBinding, secureEndpointAddress);
sender.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.LocalMachine,
StoreName.My, X509FindType.FindByThumbprint, SSLCertThumbprint);
ServicePointManager.ServerCertificateValidationCallback += new
System.Net.Security.RemoteCertificateValidationCallback(customXertificateValidation);
return sender;
}
.... // non-secure endpoint code not shown
}
We also have a custom validation method:
-------------------------------------------------------------
private static bool customXertificateValidation(object sender,
X509Certificate cert, X509Chain chain,
System.Net.Security.SslPolicyErrors error)
{
if ((error ==
System.Net.Security.SslPolicyErrors.RemoteCertificateNameMismatch) ||
(error == System.Net.Security.SslPolicyErrors.None))
return true;
// Logger is a thread-safe log-to-file method
Logger.Write("ERROR: " + error.ToString());
return false;
}
[quoted text, click to view] > And, you say the "the error the server gets (...)". Isn't the other way
> around?
The architecture uses dual-channel communications.
On a request, the client posts to the server's endpoint. This works
for the server's secured and non-secured endpoints.
On a response, the server posts to the client's endpoint. This works
only for a non-secured client endpoint. When the client is using a
secured endpoint, and the server tries to respond to that endpoint,
the server gets the "forbidden with client authentication scheme
'Anonymous' error).
Here are some other items which may or may not be important:
The server is running on Windows Server 2003 Standard Edition Service
Pack 2, the client is on Windows XP Professional Version 2002 Service
Pack 2.
When the client system was initially set up, IIS was not installed.
Once the problem with secure endpoints was discovered, I installed IIS
from an XP SP2 CD. It was not the same CD that was used for the
original XP install.
Both client and server are using the same certificate to secure their
endpoints.