Skip to content

Commit 37cb29c

Browse files
Revert "Only check ALPN if TLS extensions are enabled"
This reverts commit 5fb58fe.
1 parent 5fb58fe commit 37cb29c

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

okhttp/src/main/java/io/grpc/okhttp/TlsServerHandshakerSocketFactory.java

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,13 @@ public HandshakeResult handshake(Socket socket, Attributes attributes) throws IO
5555
SSLSocket sslSocket = (SSLSocket) socket;
5656
sslSocket.setUseClientMode(false);
5757
connectionSpec.apply(sslSocket, false);
58-
if (connectionSpec.supportsTlsExtensions()) {
59-
Protocol expectedProtocol = Protocol.HTTP_2;
60-
String negotiatedProtocol = OkHttpProtocolNegotiator.get().negotiate(
61-
sslSocket,
62-
null,
63-
Collections.singletonList(expectedProtocol)
64-
);
65-
if (!expectedProtocol.toString().equals(negotiatedProtocol)) {
66-
throw new IOException("Expected NPN/ALPN " + expectedProtocol + ": " + negotiatedProtocol);
67-
}
58+
Protocol expectedProtocol = Protocol.HTTP_2;
59+
String negotiatedProtocol = OkHttpProtocolNegotiator.get().negotiate(
60+
sslSocket,
61+
null,
62+
connectionSpec.supportsTlsExtensions() ? Collections.singletonList(expectedProtocol) : null);
63+
if (!expectedProtocol.toString().equals(negotiatedProtocol)) {
64+
throw new IOException("Expected NPN/ALPN " + expectedProtocol + ": " + negotiatedProtocol);
6865
}
6966
attributes = result.attributes.toBuilder()
7067
.set(GrpcAttributes.ATTR_SECURITY_LEVEL, SecurityLevel.PRIVACY_AND_INTEGRITY)

0 commit comments

Comments
 (0)