Skip to content

Commit

Permalink
String + int are preferable over InetSocketAddress for simplicity.
Browse files Browse the repository at this point in the history
  • Loading branch information
ganskef committed May 31, 2015
1 parent 47dd689 commit 59ce094
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
15 changes: 8 additions & 7 deletions src/main/java/org/littleshoot/proxy/MitmManager.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.littleshoot.proxy;

import java.net.InetSocketAddress;

import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;

Expand All @@ -13,14 +11,17 @@ public interface MitmManager {
/**
* Creates an {@link SSLEngine} for encrypting the server connection.
*
* @param remoteAddress
* to start a client connection to the server. Peer information
* is needed to send the server_name extension in handshake with
* Server Name Indication (SNI).
* Note: Peer information is needed to send the server_name extension in
* handshake with Server Name Indication (SNI).
*
* @param peerHost
* to start a client connection to the server.
* @param peerPort
* to start a client connection to the server.
*
* @return
*/
SSLEngine serverSslEngine(InetSocketAddress remoteAddress);
SSLEngine serverSslEngine(String peerHost, int peerPort);

/**
* <p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.littleshoot.proxy.extras;

import java.net.InetSocketAddress;

import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLSession;

Expand All @@ -15,9 +13,8 @@ public class SelfSignedMitmManager implements MitmManager {
new SelfSignedSslEngineSource(true);

@Override
public SSLEngine serverSslEngine(InetSocketAddress remoteAddress) {
return selfSignedSslEngineSource.newSslEngine(
remoteAddress.getHostName(), remoteAddress.getPort());
public SSLEngine serverSslEngine(String peerHost, int peerPort) {
return selfSignedSslEngineSource.newSslEngine(peerHost, peerPort);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -543,8 +543,10 @@ private void initializeConnectionFlow() {
boolean isMitmEnabled = mitmManager != null;

if (isMitmEnabled) {
connectionFlow.then(serverConnection.EncryptChannel(
mitmManager.serverSslEngine(remoteAddress)))
connectionFlow
.then(serverConnection.EncryptChannel(mitmManager
.serverSslEngine(remoteAddress.getHostName(),
remoteAddress.getPort())))
.then(clientConnection.RespondCONNECTSuccessful)
.then(serverConnection.MitmEncryptClientChannel);
} else {
Expand Down

0 comments on commit 59ce094

Please sign in to comment.