Skip to content

Commit 651e43d

Browse files
Clarify what verifier is
1 parent 0ba229a commit 651e43d

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed
Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(host, port);
2-
socket.startHandshake();
3-
boolean successful = verifier.verify(host, socket.getSession());
4-
if (!successful) {
5-
socket.close();
6-
throw new SSLException("Oops! Hostname verification failed!");
7-
}
8-
return socket;
1+
public SSLSocket connect(String host, int port, HostnameVerifier verifier) {
2+
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(host, port);
3+
socket.startHandshake();
4+
boolean successful = verifier.verify(host, socket.getSession());
5+
if (!successful) {
6+
socket.close();
7+
throw new SSLException("Oops! Hostname verification failed!");
8+
}
9+
return socket;
10+
}
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(host, port);
2-
socket.startHandshake();
3-
verifier.verify(host, socket.getSession());
4-
return socket;
1+
public SSLSocket connect(String host, int port, HostnameVerifier verifier) {
2+
SSLSocket socket = (SSLSocket) SSLSocketFactory.getDefault().createSocket(host, port);
3+
socket.startHandshake();
4+
verifier.verify(host, socket.getSession());
5+
return socket;
6+
}

0 commit comments

Comments
 (0)