Skip to content
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
12 changes: 11 additions & 1 deletion src/main/java/org/apache/commons/net/ftp/FTPClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -828,10 +828,20 @@ protected void _parseExtendedPassiveModeReply(String reply) throws MalformedServ
throw new MalformedServerReplyException("Could not parse extended passive host information.\nServer Reply: " + reply);
}
// in EPSV mode, the passive host address is implicit
passiveHost = getRemoteAddress().getHostAddress();
passiveHost = resolveExtendedPassiveModeHost();
passivePort = port;
}

/**
* Resolve the host for extended passive mode.
*
* @since 3.14.0
* @return the passive host
*/
protected String resolveExtendedPassiveModeHost() {
return getRemoteAddress().getHostAddress();
}

/**
* Parses a reply.
*
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/org/apache/commons/net/ftp/FTPSClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -1119,5 +1119,14 @@ protected void sslNegotiation() throws IOException {
throw new SSLHandshakeException("Hostname doesn't match certificate");
}
}

@Override
protected String resolveExtendedPassiveModeHost() {
if (_socket_ instanceof SSLSocket) {
return ((SSLSocket) _socket_).getSession().getPeerHost();
} else {
return super.resolveExtendedPassiveModeHost();
}
}
}

Loading