Axis 2 and WCF
I’m developping an Axis2 webservice with a WCF-based .Net client application. The service supports two authentication methods :
- Basic HTTP authentication
- WS-Security with Username token
Both use SSL: even if you use WS-Security and password digest, it’s not secure enough (you need to use WS-Signature and WS-Encrypt and it’s not that simple in terms of deployment). So in the app.config file of the .Net client you have an endpoint configuration with an HTTPS address:
<endpoint address=“https://localhost:8443…” … />
But if you use a self-signed certificate (for a development machine) you can get a security exception :
System.ServiceModel.Security.SecurityNegotiationException was unhandled
Message="Could not establish trust relationship for the SSL/TLS secure channel with authority “localhost:8443"”
A workaround is to handle the certificate validation:
proxy = new MyPortTypeClient(“MySOAP11port_http”);
proxy.ClientCredentials.UserName.UserName = txtBxUser.Text;
proxy.ClientCredentials.UserName.Password = txtBxPassword.Text;
System.Net.ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(debugValidation);
The debugValidation delegate method returns always true :
private static bool debugValidation(object sender, X509Certificate cert, X509Chain chain, System.Net.Security.SslPolicyErrors error){ return true; }
When using Basic authentication method you should set this property to avoid a “505 HTTP version not supported” error :
System.Net.ServicePointManager.Expect100Continue = false;
Billet publié dans les rubriques Programmation le