Reflect CSR generation failure in diagnostic screen

Summary:
The CSR generation code is written in C-like code with no excpetions because so is openssl, with no RAII structures.
So we don't have fine-grained insight on what could go wrong, but at least if it fails altogether we should error.

Reviewed By: passy

Differential Revision: D13233725

fbshipit-source-id: 75cb3c21144b591947f686b5ad529a14a011baa8
This commit is contained in:
John Knox
2018-11-29 07:01:30 -08:00
committed by Facebook Github Bot
parent 14431e6b76
commit 6c4467a03d

View File

@@ -1,3 +1,10 @@
/*
* Copyright (c) Facebook, Inc.
*
* This source code is licensed under the MIT license found in the LICENSE
* file in the root directory of this source tree.
*
*/
#include "ConnectionContextStore.h" #include "ConnectionContextStore.h"
#include <folly/json.h> #include <folly/json.h>
#include <folly/portability/SysStat.h> #include <folly/portability/SysStat.h>
@@ -37,10 +44,13 @@ bool ConnectionContextStore::hasRequiredFiles() {
std::string ConnectionContextStore::createCertificateSigningRequest() { std::string ConnectionContextStore::createCertificateSigningRequest() {
ensureFlipperDirExists(); ensureFlipperDirExists();
generateCertSigningRequest( bool success = generateCertSigningRequest(
deviceData_.appId.c_str(), deviceData_.appId.c_str(),
absoluteFilePath(CSR_FILE_NAME).c_str(), absoluteFilePath(CSR_FILE_NAME).c_str(),
absoluteFilePath(PRIVATE_KEY_FILE).c_str()); absoluteFilePath(PRIVATE_KEY_FILE).c_str());
if (!success) {
throw new std::runtime_error("Failed to generate CSR");
}
std::string csr = loadStringFromFile(absoluteFilePath(CSR_FILE_NAME)); std::string csr = loadStringFromFile(absoluteFilePath(CSR_FILE_NAME));
return csr; return csr;