问题描述
我正在尝试创建自己的 javax.net.ssl.SSLSocketFactory
,以便捕获所有HTTP/SSL请求,由第三方库发送并记录它们.这是在该库中调用工厂的方式(它是commons-httpclient):
I'm trying to create my own implementation of javax.net.ssl.SSLSocketFactory
, in order to catch all HTTP/SSL requests, send by a third-party library, and log them. This is how the factory is called in that library (it's commons-httpclient):
import javax.net.ssl.SSLSocketFactory;
// ...
return SSLSocketFactory.getDefault().createSocket(host, port);
当前使用的实现是com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl
.如何将其更改为自己的自定义类?
Current implementation used is com.sun.net.ssl.internal.ssl.SSLSocketFactoryImpl
. How can I change it to my own custom class?
推荐答案
来自 http://download.oracle.com/javase/1.4.2/docs/api/javax/net/ssl/SSLSocketFactory.html :
似乎您只能在JSM级别更改该属性,而不能为每个项目更改.在Windows中,您可以在Java \ jre6 \ lib \ security \ java.security中找到该文件.
It seems that you can only change that property at the JSM level, and not for each project. In Windows, you can find that file at Java\jre6\lib\security\java.security.
这篇关于如何创建自定义SSLSocketFactory?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!