0

I'm using Axis 1.4 in my client app to make SOAP calls. I am calling services over HTTPS. Some services use self signed certificates, others use certificates issued by a certificate authority.

I've used the code from this answer to add the self signed certificate to my trust store. My problem is that the truststore is being used for all calls - even the one's to servers that have a valid certificate from a CA.

Is there anyway to tell Axis to only use the truststore for servers that have self signed certificates ?

Community
  • 1
  • 1
Kevin
  • 11,521
  • 22
  • 81
  • 103

1 Answers1

2

It's essentially the same issue as here (except that this was for client-certificate authentication).

You'll need to create your own socket factory class and pass it to axis using this property:

AxisProperties.setProperty("axis.socketSecureFactory",
    "com.example.MySSLSocketFactory");

(See org.apache.axis.components.net.SecureSocketFactory.)

Since you already have a working SSLContext, instead of setting it as the default context, you need to create a javax.net.ssl.SSLSocketFactory from it and use this to create the socket within the Apache Axis socket factory.

Community
  • 1
  • 1
Bruno
  • 119,590
  • 31
  • 270
  • 376
  • 1
    Bruno:This a central configuration right?Is it possible to configure different socketfactories per request? – Cratylus Nov 13 '12 at 21:47
  • I would also like to configure per request. Does anyone know how to do this? @Cratylus did you find out how to do this? – ademartini Dec 04 '14 at 18:15
  • @ademartini:I implemented my own socket factory class as the answer recommended – Cratylus Dec 09 '14 at 19:23