On Jun 10, 8:46 am, Marc Gravell <marc.grav...@g mail.comwrote:
If I misunderstood, and the issue is *using* the SSL web-service at
runtime, then you'll need to write some code. For wse/wse3 you can add
to the ClientCertifica tes collection; for WCF (which is what I
understand for "service reference"), there
is .ClientCredenti als.ClientCerti ficate; either set .Certificate, or
call .SetCertificate (). I think you can also do this via config, but I
can't remember how exactly off-hand.
Marc
Hi Marc,
Thanks for your replies. The web service I am trying to connect to
needs an ssl certificate otherwise I cannot connect to it. I have
tried using the code below but I keep getting "Unable to connect to
the remote server". I have also made sure that it ignores all
certifcate error but that also doesn't work.
webRequest.Clie ntCertificates. Add(GetCertific ate());
private X509Certificate GetCertificate( )
{
///Set store to LocalMachine as this is where the
certificates must be installed
X509Store store = new X509Store(Store Name.My,
StoreLocation.L ocalMachine);
store.Open(Open Flags.ReadOnly) ;
///Find certificate based on it's name
X509Certificate 2Collection certificates =
store.Certifica tes.Find(X509Fi ndType.FindBySu bjectName, this.sslName,
true);
return certificates[0];
}
The following code which is in the constructor of the class ignores
the ssl cert errors.
ServicePointMan ager.ServerCert ificateValidati onCallback =
TrustAllCertifi cateCallback;
public static bool TrustAllCertifi cateCallback(ob ject sender,
X509Certificate cert, X509Chain chain, SslPolicyErrors
errors)
{
return true;
}