How to debugg the client using Fiddler or sth else #1058
Closed
Description
Describe what you would like to know or do
I'd like to debug my websocket client using Fiddler
Describe the solution you'd considered
I've tried proxy
like this, but it reports cert error.
ExampleClient c = new ExampleClient(new URI("wss://a-site-to-test.com:12345"));
c.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 8888)));
c.connect();
I googled that and copied a factory to trust all certs. The client works, but the https stream didn't goto Fiddler
ExampleClient c = new ExampleClient(new URI("wss://a-site-to-test.com:12345"));
c.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 8888)));
c.setSocketFactory(TrustAllCertSSLUtil.getFactory());
c.connect();
Additional context
TrustAllCertSSLUtil.java
public class TrustAllCertSSLUtil implements TrustManager, X509TrustManager {
private TrustAllCertSSLUtil() {
}
private static SSLSocketFactory sslFactory = null;
public static SSLSocketFactory getFactory() throws Exception {
if (sslFactory == null) {
TrustManager[] trustAllCerts = new TrustManager[1];
TrustManager tm = new TrustAllCertSSLUtil();
trustAllCerts[0] = tm;
SSLContext sc = SSLContext.getInstance("SSL");
sc.init(null, trustAllCerts, null);
sslFactory = sc.getSocketFactory();
}
return sslFactory;
}
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return null;
}
public boolean isServerTrusted(java.security.cert.X509Certificate[] certs) {
return true;
}
public boolean isClientTrusted(java.security.cert.X509Certificate[] certs) {
return true;
}
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType)
throws java.security.cert.CertificateException {
return;
}
public void checkClientTrusted(java.security.cert.X509Certificate[] certs, String authType)
throws java.security.cert.CertificateException {
return;
}
}