merlimat closed pull request #2172: If auth is badly configured in c++, close
the connection
URL: https://github.com/apache/incubator-pulsar/pull/2172
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/pulsar-client-cpp/lib/ClientConnection.cc
b/pulsar-client-cpp/lib/ClientConnection.cc
index 8d8243cd6a..4e6d0f23b6 100644
--- a/pulsar-client-cpp/lib/ClientConnection.cc
+++ b/pulsar-client-cpp/lib/ClientConnection.cc
@@ -160,6 +160,12 @@ ClientConnection::ClientConnection(const std::string&
logicalAddress, const std:
}
}
+ if (!authentication_) {
+ LOG_ERROR("Invalid authentication plugin");
+ close();
+ return;
+ }
+
AuthenticationDataPtr authData;
if (authentication_->getAuthData(authData) == ResultOk &&
authData->hasDataForTls()) {
std::string tlsCertificates = authData->getTlsCertificates();
@@ -354,6 +360,10 @@ void ClientConnection::handleSentPulsarConnect(const
boost::system::error_code&
*
*/
void ClientConnection::tcpConnectAsync() {
+ if (isClosed()) {
+ return;
+ }
+
boost::system::error_code err;
Url service_url;
if (!Url::parse(physicalAddress_, service_url)) {
diff --git a/pulsar-client-cpp/python/pulsar_test.py
b/pulsar-client-cpp/python/pulsar_test.py
index 3a5c407151..200a107d76 100755
--- a/pulsar-client-cpp/python/pulsar_test.py
+++ b/pulsar-client-cpp/python/pulsar_test.py
@@ -24,7 +24,7 @@
import os
from pulsar import Client, MessageId, \
CompressionType, ConsumerType, PartitionsRoutingMode, \
- AuthenticationTLS
+ AuthenticationTLS, Authentication
from _pulsar import ProducerConfiguration, ConsumerConfiguration
@@ -152,6 +152,23 @@ def test_tls_auth(self):
client.close()
+ def test_auth_junk_params(self):
+ certs_dir =
'/pulsar/pulsar-broker/src/test/resources/authentication/tls/'
+ if not os.path.exists(certs_dir):
+ certs_dir =
"../../pulsar-broker/src/test/resources/authentication/tls/"
+ authPlugin = "someoldjunk.so"
+ authParams = "blah"
+ client = Client(self.serviceUrlTls,
+ tls_trust_certs_file_path=certs_dir + 'cacert.pem',
+ tls_allow_insecure_connection=False,
+ authentication=Authentication(authPlugin, authParams))
+ try:
+
client.subscribe('persistent://property/cluster/namespace/my-python-topic-producer-consumer',
+ 'my-sub',
+ consumer_type=ConsumerType.Shared)
+ except:
+ pass # Exception is expected
+
def test_message_listener(self):
client = Client(self.serviceUrl)
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services