How to create custom SSLSocketFactory?

I am trying to create my own implementation of javax.net.ssl.SSLSocketFactory to catch all HTTP / SSL requests, send third party libraries and write them down. This is how the factory is called in this library (this is commons-httpclient):

 import javax.net.ssl.SSLSocketFactory; // ... return SSLSocketFactory.getDefault().createSocket(host, port); 

The current implementation used is com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl . How can I change it to my own class?

+3
source share
1 answer

From http://download.oracle.com/javase/1.4.2/docs/api/javax/net/ssl/SSLSocketFactory.html :

(...) The default implementation can be changed by setting the Security "ssl.SocketFactory.provider" property (Java security properties file) to the desired class.

For more information on defining your own security policy file, see http://download.oracle.com/javase/1.4.2/docs/guide/security/PolicyFiles.html .

It seems that you can change this property only at the JSM level, and not per project. On Windows, you can find this file in Java \ jre6 \ lib \ security \ java.security.

+7
source

Source: https://habr.com/ru/post/1441540/


All Articles