Skip to content
Open
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
16 changes: 10 additions & 6 deletions src/common/iamclient/certificateservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ Error CertificateService::Init(const std::string& iamProtectedServerURL, const s
mCertStorage = certStorage;
mInsecureConnection = insecureConnection;

auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str(), mInsecureConnection);
if (!err.IsNone()) {
return err;
}
if (mInsecureConnection) {
mCredentials = grpc::InsecureChannelCredentials();
} else {
auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str());
if (!err.IsNone()) {
return err;
}

mCredentials = credentials;
mCredentials = credentials;
}

mStub = iamanager::v6::IAMCertificateService::NewStub(
grpc::CreateCustomChannel(mIAMProtectedServerURL, mCredentials, grpc::ChannelArguments()));
Expand All @@ -51,7 +55,7 @@ Error CertificateService::Reconnect()

LOG_INF() << "Reconnect certificate service";

auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str(), mInsecureConnection);
auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str());
if (!err.IsNone()) {
return err;
}
Expand Down
9 changes: 2 additions & 7 deletions src/common/iamclient/itf/tlscredentials.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,17 @@ class TLSCredentialsItf {
* Gets MTLS configuration.
*
* @param certStorage Certificate storage.
* @param insecureConnection If true, returns insecure credentials.
* @return MTLS credentials.
*/
virtual RetWithError<std::shared_ptr<grpc::ChannelCredentials>> GetMTLSClientCredentials(
const String& certStorage, bool insecureConnection = false)
virtual RetWithError<std::shared_ptr<grpc::ChannelCredentials>> GetMTLSClientCredentials(const String& certStorage)
= 0;

/**
* Gets TLS credentials.
*
* @param insecureConnection If true, returns insecure credentials.
* @return TLS credentials.
*/
virtual RetWithError<std::shared_ptr<grpc::ChannelCredentials>> GetTLSClientCredentials(
bool insecureConnection = false)
= 0;
virtual RetWithError<std::shared_ptr<grpc::ChannelCredentials>> GetTLSClientCredentials() = 0;
};

} // namespace aos::common::iamclient
Expand Down
16 changes: 10 additions & 6 deletions src/common/iamclient/nodesservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,16 @@ Error NodesService::Init(const std::string& iamProtectedServerURL, const std::st
mCertStorage = certStorage;
mInsecureConnection = insecureConnection;

auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str(), mInsecureConnection);
if (!err.IsNone()) {
return err;
}
if (mInsecureConnection) {
mCredentials = grpc::InsecureChannelCredentials();
} else {
auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str());
if (!err.IsNone()) {
return err;
}

mCredentials = credentials;
mCredentials = credentials;
}

mStub = iamanager::v6::IAMNodesService::NewStub(
grpc::CreateCustomChannel(mIAMProtectedServerURL, mCredentials, grpc::ChannelArguments()));
Expand All @@ -52,7 +56,7 @@ Error NodesService::Reconnect()

LOG_INF() << "Reconnect nodes service";

auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str(), mInsecureConnection);
auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str());
if (!err.IsNone()) {
return err;
}
Expand Down
16 changes: 10 additions & 6 deletions src/common/iamclient/permservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ Error PermissionsService::Init(const std::string& iamProtectedServerURL, const s
mCertStorage = certStorage;
mInsecureConnection = insecureConnection;

auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str(), mInsecureConnection);
if (!err.IsNone()) {
return err;
}
if (mInsecureConnection) {
mCredentials = grpc::InsecureChannelCredentials();
} else {
auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str());
if (!err.IsNone()) {
return err;
}

mCredentials = credentials;
mCredentials = credentials;
}

mStub = iamanager::v6::IAMPermissionsService::NewStub(
grpc::CreateCustomChannel(mIAMProtectedServerURL, mCredentials, grpc::ChannelArguments()));
Expand All @@ -50,7 +54,7 @@ Error PermissionsService::Reconnect()

LOG_INF() << "Reconnect permissions service";

auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str(), mInsecureConnection);
auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str());
if (!err.IsNone()) {
return err;
}
Expand Down
16 changes: 10 additions & 6 deletions src/common/iamclient/provisioningservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ Error ProvisioningService::Init(const std::string& iamProtectedServerURL, const
mCertStorage = certStorage;
mInsecureConnection = insecureConnection;

auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str(), mInsecureConnection);
if (!err.IsNone()) {
return err;
}
if (mInsecureConnection) {
mCredentials = grpc::InsecureChannelCredentials();
} else {
auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str());
if (!err.IsNone()) {
return err;
}

mCredentials = credentials;
mCredentials = credentials;
}

mStub = iamanager::v6::IAMProvisioningService::NewStub(
grpc::CreateCustomChannel(mIAMProtectedServerURL, mCredentials, grpc::ChannelArguments()));
Expand All @@ -50,7 +54,7 @@ Error ProvisioningService::Reconnect()

LOG_INF() << "Reconnect provisioning service";

auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str(), mInsecureConnection);
auto [credentials, err] = mTLSCredentials->GetMTLSClientCredentials(mCertStorage.c_str());
if (!err.IsNone()) {
return err;
}
Expand Down
16 changes: 10 additions & 6 deletions src/common/iamclient/publiccertservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ Error PublicCertService::Init(
mIAMPublicServerURL = iamPublicServerURL;
mInsecureConnection = insecureConnection;

auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials(mInsecureConnection);
if (!err.IsNone()) {
return err;
}
if (mInsecureConnection) {
mCredentials = grpc::InsecureChannelCredentials();
} else {
auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials();
if (!err.IsNone()) {
return err;
}

mCredentials = credentials;
mCredentials = credentials;
}

mStub = iamanager::v6::IAMPublicCertService::NewStub(
grpc::CreateCustomChannel(mIAMPublicServerURL, mCredentials, grpc::ChannelArguments()));
Expand All @@ -59,7 +63,7 @@ Error PublicCertService::Reconnect()

LOG_INF() << "Reconnect public cert service";

auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials(mInsecureConnection);
auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials();
if (!err.IsNone()) {
return err;
}
Expand Down
16 changes: 10 additions & 6 deletions src/common/iamclient/publiccurrentnodeservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,17 @@ Error PublicCurrentNodeService::Init(
mIAMPublicServerURL = iamPublicServerURL;
mInsecureConnection = insecureConnection;

auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials(mInsecureConnection);
if (!err.IsNone()) {
return err;
if (mInsecureConnection) {
mCredentials = grpc::InsecureChannelCredentials();
} else {
auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials();
if (!err.IsNone()) {
return err;
}

mCredentials = credentials;
}

mCredentials = credentials;

mStub = iamanager::v6::IAMPublicCurrentNodeService::NewStub(
grpc::CreateCustomChannel(mIAMPublicServerURL, mCredentials, grpc::ChannelArguments()));

Expand All @@ -57,7 +61,7 @@ Error PublicCurrentNodeService::Reconnect()

LOG_INF() << "Reconnect public current node service";

auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials(mInsecureConnection);
auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials();
if (!err.IsNone()) {
return err;
}
Expand Down
16 changes: 10 additions & 6 deletions src/common/iamclient/publicidentityservice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,16 @@ Error PublicIdentityService::Init(
mIAMPublicServerURL = iamPublicServerURL;
mInsecureConnection = insecureConnection;

auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials(mInsecureConnection);
if (!err.IsNone()) {
return err;
}
if (mInsecureConnection) {
mCredentials = grpc::InsecureChannelCredentials();
} else {
auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials();
if (!err.IsNone()) {
return err;
}

mCredentials = credentials;
mCredentials = credentials;
}

mStub = iamanager::v6::IAMPublicIdentityService::NewStub(
grpc::CreateCustomChannel(mIAMPublicServerURL, mCredentials, grpc::ChannelArguments()));
Expand All @@ -56,7 +60,7 @@ Error PublicIdentityService::Reconnect()

LOG_INF() << "Reconnect public identity service";

auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials(mInsecureConnection);
auto [credentials, err] = mTLSCredentials->GetTLSClientCredentials();
if (!err.IsNone()) {
return err;
}
Expand Down
Loading
Loading