Skip to content

Commit

Permalink
use folly log instead of glog everywhere (#523)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #523

X-link: facebookresearch/fbpcs#2296

as title

Reviewed By: danbunnell

Differential Revision: D45925259

fbshipit-source-id: 2a1a16a7c867ab42461214c0dd6779feb780c6af
  • Loading branch information
Ruiyu Zhu authored and facebook-github-bot committed May 17, 2023
1 parent 3a91552 commit e747dd8
Showing 1 changed file with 18 additions and 18 deletions.
36 changes: 18 additions & 18 deletions fbpcf/engine/communication/SocketPartyCommunicationAgent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ void SocketPartyCommunicationAgent::openServerPortWithTls(
int sockFd,
int portNo,
std::string tlsDir) {
LOG(INFO) << "try to connect as server at port " << portNo << " with TLS";
XLOG(INFO) << "try to connect as server at port " << portNo << " with TLS";
const SSL_METHOD* method;
SSL_CTX* ctx;

Expand All @@ -218,22 +218,22 @@ void SocketPartyCommunicationAgent::openServerPortWithTls(
SSL_CTX_set_default_passwd_cb_userdata(ctx, (void*)passphrase_string.c_str());

if (ctx == nullptr) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("Could not create tls context");
}

// Load the certificate file
if (SSL_CTX_use_certificate_file(
ctx, (tlsDir + "/" + CERT_FILE).c_str(), SSL_FILETYPE_PEM) <= 0) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("Error using certificate file");
}

// Load the private key file
if (SSL_CTX_use_PrivateKey_file(
ctx, (tlsDir + "/" + PRIVATE_KEY_FILE).c_str(), SSL_FILETYPE_PEM) <=
0) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("Error using private key file");
}

Expand All @@ -244,11 +244,11 @@ void SocketPartyCommunicationAgent::openServerPortWithTls(

// Accept handshake from client
if (SSL_accept(ssl) <= 0) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("Error on accepting ssl");
}

LOG(INFO) << "connected as server at port " << portNo << " with TLS";
XLOG(INFO) << "connected as server at port " << portNo << " with TLS";

ssl_ = ssl;
}
Expand All @@ -257,7 +257,7 @@ void SocketPartyCommunicationAgent::openServerPortWithTls(
int sockFd,
int portNo,
TlsInfo tlsInfo) {
LOG(INFO) << "try to connect as server at port " << portNo << " with TLS";
XLOG(INFO) << "try to connect as server at port " << portNo << " with TLS";
const SSL_METHOD* method;
SSL_CTX* ctx;

Expand All @@ -278,23 +278,23 @@ void SocketPartyCommunicationAgent::openServerPortWithTls(
SSL_CTX_set_default_passwd_cb_userdata(ctx, (void*)passphrase_string.c_str());

if (ctx == nullptr) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("Could not create tls context");
}

// Load the certificate file
XLOGF(INFO, "Using certificate file at: {}", tlsInfo.certPath);
if (SSL_CTX_use_certificate_file(
ctx, (tlsInfo.certPath).c_str(), SSL_FILETYPE_PEM) <= 0) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("Error using certificate file");
}

// Load the private key file
XLOGF(INFO, "Using private key file at: {}", tlsInfo.keyPath);
if (SSL_CTX_use_PrivateKey_file(
ctx, (tlsInfo.keyPath).c_str(), SSL_FILETYPE_PEM) <= 0) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("Error using private key file");
}

Expand All @@ -305,11 +305,11 @@ void SocketPartyCommunicationAgent::openServerPortWithTls(

// Accept handshake from client
if (SSL_accept(ssl) <= 0) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("Error on accepting ssl");
}

LOG(INFO) << "connected as server at port " << portNo << " with TLS";
XLOG(INFO) << "connected as server at port " << portNo << " with TLS";

ssl_ = ssl;
}
Expand All @@ -330,14 +330,14 @@ void SocketPartyCommunicationAgent::openClientPortWithTls(
SSL_CTX_set_min_proto_version(ctx, TLS1_3_VERSION);

if (ctx == nullptr) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("could not create tls context");
}

SSL* ssl = SSL_new(ctx);

if (ssl == nullptr) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("could not create tls object");
}

Expand All @@ -348,7 +348,7 @@ void SocketPartyCommunicationAgent::openClientPortWithTls(
// initiate handshake with server
const int status = SSL_connect(ssl);
if (status != 1) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("could not complete tls handshake");
}

Expand Down Expand Up @@ -382,7 +382,7 @@ void SocketPartyCommunicationAgent::openClientPortWithTls(
}

if (ctx == nullptr) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("could not create tls context");
}

Expand All @@ -397,7 +397,7 @@ void SocketPartyCommunicationAgent::openClientPortWithTls(
SSL* ssl = SSL_new(ctx);

if (ssl == nullptr) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("could not create tls object");
}

Expand All @@ -412,7 +412,7 @@ void SocketPartyCommunicationAgent::openClientPortWithTls(
XLOGF(INFO, "verify result: {}", result);

if (status != 1) {
LOG(INFO) << folly::errnoStr(errno);
XLOG(INFO) << folly::errnoStr(errno);
throw std::runtime_error("could not complete tls handshake");
}

Expand Down

0 comments on commit e747dd8

Please sign in to comment.