Skip to content

Commit

Permalink
Fix SSL connection handler. (#271)
Browse files Browse the repository at this point in the history
  • Loading branch information
isoos authored Dec 13, 2023
1 parent 3e65bc8 commit 0bdc0d6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.0.4

- Fix: SSL connection problem handler.

## 3.0.3

- Using const for ConnectionSettings, SessionSettings and PoolSettings classes. ([#267](https://github.com/isoos/postgresql-dart/pull/267) by [Gerrel](https://github.com/Gerrel))
Expand Down
19 changes: 16 additions & 3 deletions lib/src/v3/connection.dart
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ class PgConnectionImplementation extends _PgSessionBase implements Connection {
// ignore: cancel_subscriptions
final subscription = socket.listen(
(data) {
if (sslCompleter.isCompleted) {
return;
}
if (data.length != 1) {
sslCompleter.completeError(PgException(
'Could not initialize SSL connection, received unknown byte stream.'));
Expand All @@ -251,9 +254,19 @@ class PgConnectionImplementation extends _PgSessionBase implements Connection {

sslCompleter.complete(data.first);
},
onDone: () => sslCompleter.completeError(PgException(
'Could not initialize SSL connection, connection closed during handshake.')),
onError: sslCompleter.completeError,
onDone: () {
if (sslCompleter.isCompleted) {
return;
}
sslCompleter.completeError(PgException(
'Could not initialize SSL connection, connection closed during handshake.'));
},
onError: (e) {
if (sslCompleter.isCompleted) {
return;
}
sslCompleter.completeError(e);
},
);

Stream<Uint8List> adaptedStream;
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: postgres
description: PostgreSQL database driver. Supports statement reuse and binary protocol and connection pooling.
version: 3.0.3
version: 3.0.4
homepage: https://github.com/isoos/postgresql-dart
topics:
- sql
Expand Down

0 comments on commit 0bdc0d6

Please sign in to comment.