Files
flipper/xplat/Flipper/ConnectionContextStore.h
Lorenzo Blasa 37b87b7653 ConnectionContextStore to expose API to retrieve store items path
Summary:
^

This change allow callers to retrieve the path of different store items some of which are used for connection authentication.

Reviewed By: aigoncharov

Differential Revision: D34081942

fbshipit-source-id: c6b8d3590993de6c48a36266a5c16f2caf9f5a93
2022-02-09 06:31:14 -08:00

61 lines
1.6 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:
enum StoreItem {
CSR,
FLIPPER_CA,
CLIENT_CERT,
PRIVATE_KEY,
CERTIFICATE,
CONNECTION_CONFIG,
};
ConnectionContextStore(DeviceData deviceData);
bool hasRequiredFiles();
std::string getCertificateSigningRequest();
std::shared_ptr<folly::SSLContext> getSSLContext();
std::string getCertificateDirectoryPath();
std::string getCACertificatePath();
std::string getDeviceId();
std::string getPath(StoreItem storeItem);
/**
* 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