org.littleshoot.proxy.extras.SelfSignedMitmManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of littleproxy Show documentation
Show all versions of littleproxy Show documentation
LittleProxy is a high performance HTTP proxy written in Java and using the Netty networking framework.
package org.littleshoot.proxy.extras;
import io.netty.handler.codec.http.HttpRequest;
import org.littleshoot.proxy.MitmManager;
import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;
/**
* {@link MitmManager} that uses self-signed certs for everything.
*/
public class SelfSignedMitmManager implements MitmManager {
private final SelfSignedSslEngineSource selfSignedSslEngineSource;
public SelfSignedMitmManager() {
selfSignedSslEngineSource = new SelfSignedSslEngineSource(true);
}
SelfSignedMitmManager(String keyStorePath, boolean trustAllServers, boolean sendCerts) {
selfSignedSslEngineSource = new SelfSignedSslEngineSource(keyStorePath, trustAllServers, sendCerts);
}
public SelfSignedMitmManager(SelfSignedSslEngineSource selfSignedSslEngineSource) {
this.selfSignedSslEngineSource = selfSignedSslEngineSource;
}
@Override
public SSLEngine serverSslEngine(String peerHost, int peerPort) {
return selfSignedSslEngineSource.newSslEngine(peerHost, peerPort);
}
@Override
public SSLEngine serverSslEngine() {
return selfSignedSslEngineSource.newSslEngine();
}
@Override
public SSLEngine clientSslEngineFor(HttpRequest httpRequest, SSLSession serverSslSession) {
return selfSignedSslEngineSource.newSslEngine();
}
}