Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SSL connection handler. #271

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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