From b7be3af34bba6a6f2ea2862e8d5397cbcda59abc Mon Sep 17 00:00:00 2001 From: Sigurd Meldgaard Date: Thu, 22 Aug 2019 14:26:29 +0200 Subject: [PATCH] Fix use of authority when making a secure connection --- CHANGELOG.md | 5 +++++ lib/src/client/http2_connection.dart | 16 +++++----------- pubspec.yaml | 2 +- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11313c8..aae8a88 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +## 2.1.1 + +* Fix bug introduced in 2.1.0 where an explicit `authority` would not be used when making a secure + connection. + ## 2.1.0 * Do a health check of the http2-connection before making request. diff --git a/lib/src/client/http2_connection.dart b/lib/src/client/http2_connection.dart index 303f823..81886e3 100644 --- a/lib/src/client/http2_connection.dart +++ b/lib/src/client/http2_connection.dart @@ -77,19 +77,13 @@ class Http2ClientConnection implements connection.ClientConnection { Future connectTransport() async { final securityContext = credentials.securityContext; - Socket socket; - if (securityContext == null) { - socket = await Socket.connect(host, port); - } else { - socket = await SecureSocket.connect(host, port, - supportedProtocols: ['h2'], + Socket socket = await Socket.connect(host, port); + if (securityContext != null) { + // Todo(sigurdm): We want to pass supportedProtocols: ['h2']. http://dartbug.com/37950 + socket = await SecureSocket.secure(socket, + host: authority, context: securityContext, onBadCertificate: _validateBadCertificate); - if ((socket as SecureSocket).selectedProtocol != 'h2') { - socket.destroy(); - throw (TransportException( - 'Endpoint $host:$port does not support http/2 via ALPN')); - } } final connection = ClientTransportConnection.viaSocket(socket); diff --git a/pubspec.yaml b/pubspec.yaml index eda2b10..28682ed 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,7 +1,7 @@ name: grpc description: Dart implementation of gRPC, a high performance, open-source universal RPC framework. -version: 2.1.0 +version: 2.1.1 author: Dart Team homepage: https://github.com/dart-lang/grpc-dart