Our vendor gave us webservices developed using java with message encrypted(WSS),and we have three certificates as below
1) Client Certifcate(our private key and public key)
2) Server Certificate (vendor public key)
3) 2 way ssl certificate
can somebody help me to consume the java web service in our .net client?
specifically I am not sure how to add these 3 certificates in .net client
What I have tried:
I have tried with .net cosole application to consume but not sure where to add the 2way ssl certificate.
I have tried with these code:
var b = new CustomBinding();
var sec = (AsymmetricSecurityBindingElement)SecurityBindingElement.CreateMutualCertificateBindingElement(MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10);
sec.MessageSecurityVersion = MessageSecurityVersion.WSSecurity10WSTrust13WSSecureConversation13WSSecurityPolicy12BasicSecurityProfile10;
sec.IncludeTimestamp = true;
sec.MessageProtectionOrder = System.ServiceModel.Security.MessageProtectionOrder.SignBeforeEncrypt;
b.Elements.Add(sec);
b.Elements.Add(new TextMessageEncodingBindingElement(MessageVersion.Soap11, Encoding.UTF8));
b.Elements.Add(new HttpsTransportBindingElement());
var c = new serRef.VendorServicePortTypeClient(b,
new EndpointAddress(new Uri("end point url"),
new DnsEndpointIdentity("identiyname"), new AddressHeaderCollection()));
c.ClientCredentials.ClientCertificate.SetCertificate(System.Security.Cryptography.X509Certificates.StoreLocation.LocalMachine,
System.Security.Cryptography.X509Certificates.StoreName.My, System.Security.Cryptography.X509Certificates.X509FindType.FindBySerialNumber, "xxxxxxxxxxxx");
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
c.ClientCredentials.ServiceCertificate.Authentication.CertificateValidationMode = System.ServiceModel.Security.X509CertificateValidationMode.None;
c.ClientCredentials.ServiceCertificate.DefaultCertificate = new X509Certificate2(@"ServerPublicKey.cer");
c.Endpoint.Contract.ProtectionLevel = System.Net.Security.ProtectionLevel.Sign;
string a = "";
string a2 = "";
var x= c.Ping(out a,out a2);