Initiate cert exchange when medium changes
Summary: Changelog: Initiate cert exchange when medium changes Fixes the following bug: 1. Start an iOS app with WWW cert exchange 2. Get cert (and fake serial of a virtual device) 3. Close app 4. Restart Flipper 5. Switch app to FS_ACCESS cert exchange 6. Start app Expected result: App re-initializes cert exchange to get a new serial of a real device Current result: App tries to connect securely using the previous fake serial of a virtual device. Flipper does not recognize it and refuses the connection. Reviewed By: lblasa Differential Revision: D33163798 fbshipit-source-id: 67126a9b562f2cb7cfe6521a46abf38b2699fb2d
This commit is contained in:
committed by
Facebook GitHub Bot
parent
95529e3d6e
commit
6a8135af38
@@ -6,6 +6,7 @@
|
||||
*/
|
||||
|
||||
#include "ConnectionContextStore.h"
|
||||
#include <folly/Optional.h>
|
||||
#include <folly/json.h>
|
||||
#include <folly/portability/SysStat.h>
|
||||
#include <openssl/err.h>
|
||||
@@ -110,6 +111,21 @@ std::string ConnectionContextStore::getDeviceId() {
|
||||
}
|
||||
}
|
||||
|
||||
folly::Optional<FlipperCertificateExchangeMedium>
|
||||
ConnectionContextStore::getLastKnownMedium() {
|
||||
try {
|
||||
std::string config =
|
||||
loadStringFromFile(absoluteFilePath(CONNECTION_CONFIG_FILE));
|
||||
auto maybeMedium = folly::parseJson(config)["medium"];
|
||||
return maybeMedium.isInt()
|
||||
? folly::Optional<FlipperCertificateExchangeMedium>{static_cast<
|
||||
FlipperCertificateExchangeMedium>(maybeMedium.getInt())}
|
||||
: folly::none;
|
||||
} catch (std::exception&) {
|
||||
return folly::none;
|
||||
}
|
||||
}
|
||||
|
||||
void ConnectionContextStore::storeConnectionConfig(folly::dynamic& config) {
|
||||
std::string json = folly::toJson(config);
|
||||
writeStringToFile(json, absoluteFilePath(CONNECTION_CONFIG_FILE));
|
||||
|
||||
Reference in New Issue
Block a user