Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adamfisk#337 - SNI headers not being sent for outbound proxies. #396

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.littleshoot.proxy.TransportProtocol;
import org.littleshoot.proxy.UnknownTransportProtocolException;

import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLProtocolException;
import javax.net.ssl.SSLSession;
import java.io.IOException;
Expand Down Expand Up @@ -545,16 +546,18 @@ private void initializeConnectionFlow() {
.then(ConnectChannel);

if (chainedProxy != null && chainedProxy.requiresEncryption()) {
connectionFlow.then(serverConnection.EncryptChannel(chainedProxy
.newSslEngine()));
InetSocketAddress proxyAddress = chainedProxy.getChainedProxyAddress();
SSLEngine engine = proxyAddress.isUnresolved() ? chainedProxy.newSslEngine() :
chainedProxy.newSslEngine(proxyAddress.getHostName(), proxyAddress.getPort());
connectionFlow.then(serverConnection.EncryptChannel(engine));
}

if (ProxyUtils.isCONNECT(initialRequest)) {
// If we're chaining, forward the CONNECT request
if (hasUpstreamChainedProxy()) {
connectionFlow.then(
serverConnection.HTTPCONNECTWithChainedProxy);
}
}

MitmManager mitmManager = proxyServer.getMitmManager();
boolean isMitmEnabled = mitmManager != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public boolean requiresEncryption() {
public SSLEngine newSslEngine() {
return clientSslEngineSource.newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return clientSslEngineSource.newSslEngine(peerHost, peerPort);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ public boolean requiresEncryption() {
public SSLEngine newSslEngine() {
return clientSslEngineSource.newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return clientSslEngineSource.newSslEngine(peerHost, peerPort);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public boolean requiresEncryption() {
public SSLEngine newSslEngine() {
return serverSslEngineSource.newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return serverSslEngineSource.newSslEngine(peerHost, peerPort);
}
});
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public boolean requiresEncryption() {
public SSLEngine newSslEngine() {
return clientSslEngineSource.newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return clientSslEngineSource.newSslEngine(peerHost, peerPort);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public boolean requiresEncryption() {
public SSLEngine newSslEngine() {
return sslEngineSource.newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return sslEngineSource.newSslEngine(peerHost, peerPort);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public boolean requiresEncryption() {
public SSLEngine newSslEngine() {
return sslEngineSource.newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return sslEngineSource.newSslEngine(peerHost, peerPort);
}
};
}
}
5 changes: 5 additions & 0 deletions src/test/java/org/littleshoot/proxy/HttpFilterTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,11 @@ public SSLEngine newSslEngine() {
// use the same "bad" keystore as BadServerAuthenticationTCPChainedProxyTest
return new SelfSignedSslEngineSource("chain_proxy_keystore_2.jks").newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return new SelfSignedSslEngineSource("chain_proxy_keystore_2.jks").newSslEngine(peerHost, peerPort);
}
});
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public boolean requiresEncryption() {
public SSLEngine newSslEngine() {
return clientSslEngineSource.newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return clientSslEngineSource.newSslEngine(peerHost, peerPort);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public boolean requiresEncryption() {
public SSLEngine newSslEngine() {
return clientSslEngineSource.newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return clientSslEngineSource.newSslEngine(peerHost, peerPort);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public boolean requiresEncryption() {
public SSLEngine newSslEngine() {
return clientSslEngineSource.newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return clientSslEngineSource.newSslEngine(peerHost, peerPort);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public boolean requiresEncryption() {
public SSLEngine newSslEngine() {
return sslEngineSource.newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return sslEngineSource.newSslEngine(peerHost, peerPort);
}
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public boolean requiresEncryption() {
public SSLEngine newSslEngine() {
return sslEngineSource.newSslEngine();
}

@Override
public SSLEngine newSslEngine(String peerHost, int peerPort) {
return sslEngineSource.newSslEngine(peerHost, peerPort);
}
};
}
}