I really hope someone here can help. Let me also preface my question by saying that I am not a .NET expert and have very little knowledge of web services and SSL / security issues.
I am trying to create a VB.NET console application to use a Java-based web service hosted on an Apache server. Communication is via SSL. A client certificate is required (provided by web service providers), and basic authentication (username / password) is also required to use the service.
In the installed certificate (using certmgr.mgr) from the provided PFX file and the certificate is stored in both my personal storage and the Trusted Root storage. I did not check all the boxes for strong encryption (used by default for everyone).
I created a proxy class for the service using the provided WSDL file. The WSDL that resides on their server is incorrect and cannot be used for early binding in .NET. I created a proxy class using "SVCUTIL * .wsdl / language: VB".
I get the following error when trying to call one of the public methods from the service:
An error occurred while sending the HTTP request to "https: // webservice-url? WSDL". This may be because the server certificate is not configured properly with HTTP.SYS in the case of HTTPS. This can also be caused by a mismatch in the security binding between the client and server.
If I look at an InnerException from an Exception snapshot, I see the following:
The connected connection was closed: an unexpected error occurred while sending.
Here is the code I used to initialize the client and connect to the web service:
'Override server certificate callback Dim oCertOverride As New CertificateOverride ServicePointManager.ServerCertificateValidationCallback = _ AddressOf oCertOverride.RemoteCertificateValidationCallback 'Set WS binding Dim binding As WSHttpBinding = New WSHttpBinding binding.Security.Mode = SecurityMode.Transport binding.Security.Transport.ClientCredentialType = _ HttpClientCredentialType.Certificate 'Set endpoint address Dim address As EndpointAddress = _ New EndpointAddress("https://webservice-url?WSDL") 'Create web service client Dim ws As wsclient = New wsclient(binding, address) 'Set web service client certificate ws.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, _ StoreName.My, X509FindType.FindBySubjectName, "cert-subject-name") 'Set username and password for server authentication ws.ClientCredentials.UserName.UserName = "username" ws.ClientCredentials.UserName.Password = "password" 'Make test call to web service ws.HelloWord()
I should also note that I can connect to the web service and view all public methods using Firefox and IE.
I tried the internet for help. Most quick fixes that worked for people did not help. I played with the bind settings, but this led to various errors in the fact that you cannot connect to the web service using the Anonymous User account.
I am really at a loss. Any advice or help would be greatly appreciated.
Thank you for your time.