Skip to content

Commit f171c9a

Browse files
author
oleksiys
committedJul 15, 2014
[master] + rework (#2) the fix for the issue #525
#525 "Move the hostname verification to after the SSL handshake has completed"
1 parent 442c146 commit f171c9a

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed
 

‎providers/grizzly/src/main/java/org/asynchttpclient/providers/grizzly/filters/SwitchingSSLFilter.java

+18-12
Original file line numberDiff line numberDiff line change
@@ -191,20 +191,26 @@ public void failed(final Throwable throwable) {
191191
}
192192

193193
public void completed(final Connection connection) {
194-
final SSLSession session = SSLUtils.getSSLEngine(connection).getSession();
195-
if (LOGGER.isDebugEnabled()) {
196-
LOGGER.debug("SSL Handshake onComplete: session = {}, id = {}, isValid = {}, host = {}",
197-
session.toString(), Base64.encode(session.getId()), session.isValid(), host);
198-
}
194+
if (getHandshakeError(connection) == null) {
195+
final SSLSession session = SSLUtils.getSSLEngine(connection).getSession();
196+
if (LOGGER.isDebugEnabled()) {
197+
LOGGER.debug("SSL Handshake onComplete: session = {}, id = {}, isValid = {}, host = {}",
198+
session.toString(), Base64.encode(session.getId()), session.isValid(), host);
199+
}
200+
201+
if (!verifier.verify(host, session)) {
202+
connection.terminateSilently();
199203

200-
if (!verifier.verify(host, session)) {
201-
connection.terminateSilently();
202-
203-
if (delegateCompletionHandler != null) {
204-
IOException e = new ConnectException("Host name verification failed for host " + host);
205-
delegateCompletionHandler.failed(e);
204+
if (delegateCompletionHandler != null) {
205+
IOException e = new ConnectException("Host name verification failed for host " + host);
206+
delegateCompletionHandler.failed(e);
207+
}
208+
209+
return;
206210
}
207-
} else if (delegateCompletionHandler != null) {
211+
}
212+
213+
if (delegateCompletionHandler != null) {
208214
delegateCompletionHandler.completed(connection);
209215
}
210216
}

0 commit comments

Comments
 (0)