-
I am writing a program that is using Secret Manager from the SDK. It also uses Socket.IO My problem appears to be tied to SSL. Socket.IO was built first and is using the system installed libssl ( If I remove the system libssl, linking fails due to missing functions. Any ideas here? Is my only option to rebuild gPRC without the A test program that reproduces the segfault #include <iostream>
#include "dotenv.h"
#include <sio_client.h>
#include <google/cloud/secretmanager/v1/secret_manager_client.h>
namespace secretmanager = ::google::cloud::secretmanager_v1;
static std::mutex smMutex;
static secretmanager::SecretManagerServiceClient *client = nullptr;
std::string getSecret()
{
std::unique_lock<std::mutex> smlock(smMutex);
std::stringstream secretKey;
std::string result;
if (client == nullptr)
{
client = new secretmanager::SecretManagerServiceClient(secretmanager::MakeSecretManagerServiceConnection());
}
secretKey << "projects/" << std::getenv("SECRET_PROJECT") << "/secrets/" << std::getenv("ENV") << '-' << std::getenv("APP") << "-" << std::getenv("PARM");
std::cout << "Looking up " << secretKey.str() << std::endl;
auto secret = client->GetSecret(secretKey.str());
if (! secret)
{
std::cerr << "Failed to find secret key " << secretKey.str() << " : " << std::move(secret).status() << std::endl;
}
else
{
secretKey << "/versions/latest";
auto request = google::cloud::secretmanager::v1::AccessSecretVersionRequest();
request.set_name(secretKey.str());
auto value = client->AccessSecretVersion(request);
if (! value)
{
std::cerr << "Failed to find secret value " << secretKey.str() << " : " << std::move(secret).status() << std::endl;
}
else if (value->has_payload())
{
result = value->payload().data();
}
else
{
std::cerr << "No payload for secret value " << secretKey.str() << " : " << std::move(secret).status() << std::endl;
}
}
smlock.unlock();
return result;
}
int main(int, char**)
{
dotenv::init("/var/www/.env");
// Comment this to prevent seg fault
sio::client client;
std::string value = getSecret();
std::cout << "Got '" << value << "'" << std::endl;
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
We have instructions in /doc/packaging.md showing how to compile gRPC using the system's SSL library. /FYI @veblush |
Beta Was this translation helpful? Give feedback.
-
Glad we could help. Closing. |
Beta Was this translation helpful? Give feedback.
We have instructions in /doc/packaging.md showing how to compile gRPC using the system's SSL library.
/FYI @veblush