Calling web service via SSL (https)
What is the trick to calling a web service accessed via https?
I can navigate OK to the web service ASMX file from IE. From time to time
when I access the web service via IE, I am asked to accept or reject the
certificate. I always accept the certificate and I have on several occasions
actually installed the certificate in the certificate store on the machine.
First, why am I being repeatedly asked to accept the certificate even after
I have installed it in the certificate store? Is it because I am not using
certificate issued by the recognized Certification Authorities such as
Verisign and Thawte (I am using Microsoft Certificate Server to issue the
server certificate for the web service site).
Secondly, when I programmatically access the web service via the web service
proxy, I get the error "The underlying connection was closed: Could not
establish trust relationship with remote server."
Now, I have exported the certificate installed in the certificate store to
X509 format. I even went so far as to export the certificate on the web site
for use on the web service client, after which I used the following piece
Dim ws As New TestWS.MyWebservice.Hello() '-- instantiate the web service
ws.Credentials = CredentialCache.DefaultCredentials '-- Pass in
Dim x509 As X509Certificate =
X509Certificate.CreateFromCertFile("c:\HelloWs.cer") '-- Load the
certificate from a file
ws.ClientCertificates.Add(x509) '-- add the certificate
ws.HelloWorld '-- call the web method
Whether I use the code above or not prior to calling the webmethod of a
webservice accessed via https, I always get the error "The underlying
connection was closed: Could not establish trust relationship with remote
Please I need some insights on how to resolve this problem.
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center