Only create CSR once per app invocation

Summary: The CSR has no need to change, don't recreate it every time we need it. Useful for the physical iOS case especially, because it connects to the portforwarder and keeps attempting to send a CSR.

Reviewed By: passy

Differential Revision: D14131617

fbshipit-source-id: 82a69d5aff813d77fa05dd13fc2441b784766d99
This commit is contained in:
John Knox
2019-02-19 10:23:53 -08:00
committed by Facebook Github Bot
parent b594fb7c76
commit 9c87dfe230
3 changed files with 8 additions and 4 deletions

View File

@@ -42,7 +42,10 @@ bool ConnectionContextStore::hasRequiredFiles() {
return true;
}
std::string ConnectionContextStore::createCertificateSigningRequest() {
std::string ConnectionContextStore::getCertificateSigningRequest() {
if (csr != "") {
return csr;
}
resetFlipperDir();
bool success = generateCertSigningRequest(
deviceData_.appId.c_str(),
@@ -51,7 +54,7 @@ std::string ConnectionContextStore::createCertificateSigningRequest() {
if (!success) {
throw new std::runtime_error("Failed to generate CSR");
}
std::string csr = loadStringFromFile(absoluteFilePath(CSR_FILE_NAME));
csr = loadStringFromFile(absoluteFilePath(CSR_FILE_NAME));
return csr;
}