|
33 | 33 | #include "PulsarApi.pb.h"
|
34 | 34 | #include "ResultUtils.h"
|
35 | 35 | #include "Url.h"
|
| 36 | +#include "auth/AuthOauth2.h" |
36 | 37 | #include "auth/InitialAuthData.h"
|
37 | 38 | #include "checksum/ChecksumProvider.h"
|
38 | 39 |
|
@@ -193,6 +194,14 @@ ClientConnection::ClientConnection(const std::string& logicalAddress, const std:
|
193 | 194 | return;
|
194 | 195 | }
|
195 | 196 |
|
| 197 | + auto oauth2Auth = std::dynamic_pointer_cast<AuthOauth2>(authentication_); |
| 198 | + if (oauth2Auth) { |
| 199 | + // Configure the TLS trust certs file for Oauth2 |
| 200 | + auto authData = std::dynamic_pointer_cast<AuthenticationDataProvider>( |
| 201 | + std::make_shared<InitialAuthData>(clientConfiguration.getTlsTrustCertsFilePath())); |
| 202 | + oauth2Auth->getAuthData(authData); |
| 203 | + } |
| 204 | + |
196 | 205 | if (clientConfiguration.isUseTls()) {
|
197 | 206 | #if BOOST_VERSION >= 105400
|
198 | 207 | boost::asio::ssl::context ctx(boost::asio::ssl::context::tlsv12_client);
|
@@ -223,8 +232,7 @@ ClientConnection::ClientConnection(const std::string& logicalAddress, const std:
|
223 | 232 | std::string tlsCertificates = clientConfiguration.getTlsCertificateFilePath();
|
224 | 233 | std::string tlsPrivateKey = clientConfiguration.getTlsPrivateKeyFilePath();
|
225 | 234 |
|
226 |
| - auto authData = std::dynamic_pointer_cast<AuthenticationDataProvider>( |
227 |
| - std::make_shared<InitialAuthData>(clientConfiguration.getTlsTrustCertsFilePath())); |
| 235 | + AuthenticationDataPtr authData; |
228 | 236 | if (authentication_->getAuthData(authData) == ResultOk && authData->hasDataForTls()) {
|
229 | 237 | tlsCertificates = authData->getTlsCertificates();
|
230 | 238 | tlsPrivateKey = authData->getTlsPrivateKey();
|
|
0 commit comments