Summary: The problem is that whenever an app is shutdown, and then reopened, the flipper dir gets reset when getting the CSR for connecting to flipper. This causes the first connection attempt to fail always, and it goes through the whole cert exchange, taking longer than necessary. Fixes it by loading the csr from disk if it's not loaded yet, without blowing away the whole certs state. A side effect of this would be that as long as some file exists where the csr lives, flipper state would never get reset, so it wouldn't be able to fix itself automatically anymore. To keep that working, I've made `resetFlipperDir()` public and am calling it explicitly when starting certificate exchange. This should ensure that we still reset when we need to, but not unnecessarily. The reason it went wrong is that getCSR used to be called only at cert exchange, when resetting and generating a new one was always desirable. However, when we shipped the fix for changeable android serials, it started to be used as a normal getter. Reviewed By: timur-valiev Differential Revision: D18834806 fbshipit-source-id: 56ca7e03e1aa9011f836bc9c021cf3048f7dc1e4
41 lines
910 B
C++
41 lines
910 B
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
#include <folly/io/async/SSLContext.h>
|
|
#include <folly/dynamic.h>
|
|
#include "FlipperInitConfig.h"
|
|
|
|
using namespace folly;
|
|
|
|
namespace facebook {
|
|
namespace flipper {
|
|
|
|
class ConnectionContextStore {
|
|
|
|
public:
|
|
ConnectionContextStore(DeviceData deviceData);
|
|
bool hasRequiredFiles();
|
|
std::string getCertificateSigningRequest();
|
|
std::shared_ptr<SSLContext> getSSLContext();
|
|
std::string getCertificateDirectoryPath();
|
|
std::string getDeviceId();
|
|
void storeConnectionConfig(folly::dynamic& config);
|
|
bool resetState();
|
|
|
|
private:
|
|
DeviceData deviceData_;
|
|
std::string csr = "";
|
|
|
|
std::string absoluteFilePath(const char* filename);
|
|
};
|
|
|
|
} // namespace flipper
|
|
} // namespace facebook
|