Files
flipper/xplat/Flipper/ConnectionContextStore.h
Andres Suarez 79023ee190 Update copyright headers from Facebook to Meta
Reviewed By: bhamodi

Differential Revision: D33331422

fbshipit-source-id: 016e8dcc0c0c7f1fc353a348b54fda0d5e2ddc01
2021-12-27 14:31:45 -08:00

52 lines
1.5 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and 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 <folly/Optional.h>
#include <folly/dynamic.h>
#include <folly/io/async/SSLContext.h>
#include <string>
#include "FlipperCertificateExchangeMedium.h"
#include "FlipperInitConfig.h"
namespace facebook {
namespace flipper {
class ConnectionContextStore {
public:
ConnectionContextStore(DeviceData deviceData);
bool hasRequiredFiles();
std::string getCertificateSigningRequest();
std::shared_ptr<folly::SSLContext> getSSLContext();
std::string getCertificateDirectoryPath();
std::string getCACertificatePath();
std::string getDeviceId();
/**
* Get medium over which the certificate was received.
*/
folly::Optional<FlipperCertificateExchangeMedium> getLastKnownMedium();
void storeConnectionConfig(folly::dynamic& config);
bool resetState();
/** Convert and save to disk the existing certificate to PKCS #12 format.
* @return Returns a pair where `first` contains the certificate file path and
* `second` contains the certificate export password. If there's an error, the
* pair will contain both empty strings.
*/
std::pair<std::string, std::string> getCertificate();
private:
DeviceData deviceData_;
std::string csr = "";
std::string absoluteFilePath(const char* filename);
};
} // namespace flipper
} // namespace facebook