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

Add tls authentication plugin for cpp client #200

Merged

Conversation

yush1ga
Copy link
Contributor

@yush1ga yush1ga commented Feb 9, 2017

Motivation

Authentication plugin for C++ client is empty.

Modifications

  • Support TLS connection
  • Add TLS authentication plugin
  • Enable performance tools to use authentication plugin

Result

C++ client can be authenticated and authorized by broker with AuthenticationProviderTls.

@merlimat merlimat added c++ type/feature The PR added a new feature or issue requested a new feature labels Feb 10, 2017
@merlimat merlimat added this to the 1.17 milestone Feb 10, 2017
Copy link
Contributor

@merlimat merlimat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@merlimat
Copy link
Contributor

@saandrews @rdhabalia Please take a look

ParamMap paramMap;
if(!authParamsString.empty()) {
std::vector<std::string> params;
boost::algorithm::split(params, authParamsString, boost::is_any_of(","));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have to worry about escaped , or : characters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is unlikely that authentication parameter's keys and values contain "," and ":" now.
Actually, Java's AuthenticationFactory implementation doesn't worry about it.
https://github.com/yahoo/pulsar/blob/2d75e88269e35ed0e9959c2ad678bd349c605436/pulsar-client/src/main/java/com/yahoo/pulsar/client/api/AuthenticationFactory.java#L42

I think we don't have to consider it right now.
What do you think ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then don't worry about it.

}
}

tlsSocket_ = executor->createTlsSocket(socket_, ctx);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we close/cleanup this socket in ClientConnection::close() ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yush1ga yush1ga force-pushed the add_tls_authentication_plugin_for_cpp_client branch from 3d49cd6 to a9e2919 Compare February 14, 2017 22:53
Copy link
Contributor

@rdhabalia rdhabalia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add any additional tls-test case with test-certificate file like we have in java-test

Authentication *auth = NULL;
void *handle = dlopen(dynamicLibPath.c_str(), RTLD_LAZY);
if (handle != NULL) {
{
Copy link
Contributor

@rdhabalia rdhabalia Feb 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we remove this extra block(curly braces) here?

keepAliveTimer_() {
keepAliveTimer_(),
isTlsAllowInsecureConnection_(false) {
if (clientConfiguration.isUseTls()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting..??

}

tlsSocket_ = executor->createTlsSocket(socket_, ctx);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we have already intitialized tlsSocket then shouldn't we initialize socket_(executor->createSocket()), at line 101 into else block here.?

Copy link
Contributor Author

@yush1ga yush1ga Feb 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should initialize socket_ at line 101 because if we don't do it, createTlsSocket doesn't work with a following error.

Assertion failed: (px != 0), function operator*, file /usr/local/include/boost/smart_ptr/shared_ptr.hpp, line 703.

}
}

template< typename MutableBufferSequence, typename ReadHandler>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting space after template<

@rdhabalia
Copy link
Contributor

@yush1ga : minor comments. looks good to me.

@yush1ga yush1ga force-pushed the add_tls_authentication_plugin_for_cpp_client branch from a9e2919 to 7e06246 Compare February 15, 2017 00:27
@yush1ga
Copy link
Contributor Author

yush1ga commented Feb 15, 2017

Broker has tls connection test but it doesn't have tls authentication test.
I will send another PR about end to end tls authentication test for both C++ and Java client.

@saandrews
Copy link
Contributor

👍

@saandrews saandrews merged commit 88e75fe into apache:master Feb 15, 2017
sijie added a commit to sijie/pulsar that referenced this pull request Mar 4, 2018
hrsakai pushed a commit to hrsakai/pulsar that referenced this pull request Dec 10, 2020
…pache#237)

add internal connectionReader readAtLeast error information
these error information may help to solve apache#200
hangc0276 pushed a commit to hangc0276/pulsar that referenced this pull request May 26, 2021
related to apache#199, keep requestsQueue order using one thread to solve Correlation ID response in disorder.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature The PR added a new feature or issue requested a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants