Skip to content
Closed
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
13 changes: 8 additions & 5 deletions src/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ void Connection::on_read_ssl(uv_stream_t* client, ssize_t nread, const uv_buf_t*
}
if (rc <= 0 && ssl_session->has_error()) {
connection->notify_error("Unable to decrypt data: " + ssl_session->error_message(),
CONNECTION_ERROR_SSL);
CONNECTION_ERROR_SSL_DECRYPT);
}
} else {
connection->ssl_handshake();
Expand Down Expand Up @@ -849,7 +849,7 @@ void Connection::notify_error(const std::string& message, ConnectionError code)
message.c_str());
error_message_ = message;
error_code_ = code;
if (code == Connection::CONNECTION_ERROR_SSL) {
if (is_ssl_error()) {
ssl_error_code_ = ssl_session_->error_code();
}
defunct();
Expand All @@ -859,7 +859,8 @@ void Connection::ssl_handshake() {
if (!ssl_session_->is_handshake_done()) {
ssl_session_->do_handshake();
if (ssl_session_->has_error()) {
notify_error("Error during SSL handshake: " + ssl_session_->error_message(), CONNECTION_ERROR_SSL);
notify_error("Error during SSL handshake: " + ssl_session_->error_message(),
CONNECTION_ERROR_SSL_HANDSHAKE);
return;
}
}
Expand All @@ -876,7 +877,8 @@ void Connection::ssl_handshake() {
if (ssl_session_->is_handshake_done()) {
ssl_session_->verify();
if (ssl_session_->has_error()) {
notify_error("Error verifying peer certificate: " + ssl_session_->error_message(), CONNECTION_ERROR_SSL);
notify_error("Error verifying peer certificate: " + ssl_session_->error_message(),
CONNECTION_ERROR_SSL_VERIFY);
return;
}
on_connected();
Expand Down Expand Up @@ -1111,7 +1113,8 @@ void Connection::PendingWriteSsl::encrypt() {
if (is_done || copied == SSL_WRITE_SIZE) {
int rc = ssl_session->encrypt(buf, copied);
if (rc <= 0 && ssl_session->has_error()) {
connection_->notify_error("Unable to encrypt data: " + ssl_session->error_message(), CONNECTION_ERROR_SSL);
connection_->notify_error("Unable to encrypt data: " + ssl_session->error_message(),
CONNECTION_ERROR_SSL_ENCRYPT);
return;
}
copied = 0;
Expand Down
12 changes: 10 additions & 2 deletions src/connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ class Connection {
CONNECTION_ERROR_TIMEOUT,
CONNECTION_ERROR_INVALID_PROTOCOL,
CONNECTION_ERROR_AUTH,
CONNECTION_ERROR_SSL,
CONNECTION_ERROR_SSL_ENCRYPT,
CONNECTION_ERROR_SSL_DECRYPT,
CONNECTION_ERROR_SSL_HANDSHAKE,
CONNECTION_ERROR_SSL_VERIFY,
CONNECTION_ERROR_KEYSPACE
};

Expand Down Expand Up @@ -130,7 +133,12 @@ class Connection {

bool is_invalid_protocol() const { return error_code_ == CONNECTION_ERROR_INVALID_PROTOCOL; }
bool is_auth_error() const { return error_code_ == CONNECTION_ERROR_AUTH; }
bool is_ssl_error() const { return error_code_ == CONNECTION_ERROR_SSL; }
bool is_ssl_error() const {
return error_code_ == CONNECTION_ERROR_SSL_ENCRYPT ||
error_code_ == CONNECTION_ERROR_SSL_DECRYPT ||
error_code_ == CONNECTION_ERROR_SSL_HANDSHAKE ||
error_code_ == CONNECTION_ERROR_SSL_VERIFY;
}
bool is_timeout_error() const { return error_code_ == CONNECTION_ERROR_TIMEOUT; }

ConnectionError error_code() const { return error_code_; }
Expand Down
3 changes: 2 additions & 1 deletion src/pool.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class Pool : public RefCounted<Pool>
bool is_critical_failure() const {
return error_code_ == Connection::CONNECTION_ERROR_INVALID_PROTOCOL ||
error_code_ == Connection::CONNECTION_ERROR_AUTH ||
error_code_ == Connection::CONNECTION_ERROR_SSL;
error_code_ == Connection::CONNECTION_ERROR_SSL_HANDSHAKE ||
error_code_ == Connection::CONNECTION_ERROR_SSL_VERIFY;
}

bool cancel_reconnect() const { return cancel_reconnect_; }
Expand Down