From 6c4467a03dfcbcbe5fc04a27e667b1d8a53fc7d8 Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 29 Nov 2018 07:01:30 -0800 Subject: [PATCH] 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 --- xplat/Flipper/ConnectionContextStore.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/xplat/Flipper/ConnectionContextStore.cpp b/xplat/Flipper/ConnectionContextStore.cpp index 410ed6fe1..0b14c375c 100644 --- a/xplat/Flipper/ConnectionContextStore.cpp +++ b/xplat/Flipper/ConnectionContextStore.cpp @@ -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 #include @@ -37,10 +44,13 @@ bool ConnectionContextStore::hasRequiredFiles() { std::string ConnectionContextStore::createCertificateSigningRequest() { ensureFlipperDirExists(); - generateCertSigningRequest( + bool success = generateCertSigningRequest( deviceData_.appId.c_str(), absoluteFilePath(CSR_FILE_NAME).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)); return csr;