Fix use of authority when making a secure connection

This commit is contained in:
Sigurd Meldgaard 2019-08-22 14:26:29 +02:00 committed by GitHub
parent 78dcb0f4f1
commit b7be3af34b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 12 deletions

View File

@ -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.

View File

@ -77,19 +77,13 @@ class Http2ClientConnection implements connection.ClientConnection {
Future<ClientTransportConnection> 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);

View File

@ -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 <misc@dartlang.org>
homepage: https://github.com/dart-lang/grpc-dart