Invoking Java web service from C# client using JKS and/or PFX certificates

I basically need to secure my requests towards this service.

I've been provided a JAR test client and two files, trust.jks and Client.pfx, but I have no clue how to use them: I understand X509Certificate2 class is involved in some way.

The command line to execute the test client is the following:

java -Djavax.net.ssl.trustStore=trust.jks -Djavax.net.ssl.trustStorePassword=******** -Djavax.net.ssl.trustStoreType=JKS -Djavax.net.ssl.keyStore=Client.pfx -Djavax.net.ssl.keyStoreType=pkcs12 -Djavax.net.ssl.keyStorePassword=******** -jar TestClient.jar https://myServiceurl

It works, so I can both see the service, and the service itself should be properly configured.

My C# client (it's targeting .NET 2.0) uses a normal Web Reference to perform requests:

wsReferenceClient service = new wsReferenceClient();
//certificate code here ?
//maybe service.ClientCertificates.Add(<X509Certificate2 object built somehow>); ?
service.MyRequest(myParameters);

Server settings should be setup properly.

I fumbled around with the X509Certificate2 methods but I can't come out with something that makes sense, so the answer to the 'what have you tried?' question at the moment is 'I don't really know what to try in the first place'.

Any help would be really appreciated.

Answers


Turns out I don't need to do anything with the JKS file.

wsReferenceClient service = new wsReferenceClient();
X509Certificate2 cert = new X509Certificate2();
cert.Import("Client.pfx", "<the password>", DefaultKeySet);
service.ClientCertificates.Add(cert);
service.MyRequest(myParameters);

This allows my HTTPS requests to go through successfully.


Need Your Help

PHP display error

php mysql

I've created the following code but for some reason it is echoing Array instead of the result:

Temporary table record limit in Sql server

sql sql-server sql-server-2008 temp-tables

Is there any limits for the record in the temporary table.. I have tried with 1.3 million records.. may be i have to deal with billions in the future as the application demands.. Is it possible? I...