Simplify CertificateProvider setup
Summary:
Currently, certificateSetup is called in two places:
- processCertificateSigningRequest
- loadSecureServerConfig
`loadSecureServerConfig` is a mandatory step of Flipper server initialization ([ServerController.init](https://www.internalfb.com/code/flipper/[24785758018a2ffbd4751ad2b9093b5ef97c611d]/src/fbsource/xplat/sonar/desktop/flipper-server-core/src/comms/ServerController.tsx?lines=118)). Flipper cannot start without executing it.
As a result, calling `certificateSetup` in `processCertificateSigningRequest` always results in the early return.
This diff removes executing `certificateSetup` from `processCertificateSigningRequest`. Since it's called only during server setup (so only once), it no longer makes sense to use `didCertificateSetup`.
Next steps:
- Extract Android and iOS certificate utils. Remove the dependency on accessing adb/idb dynamically. See D33711652 (da618fd3f3).
Reviewed By: jknoxville
Differential Revision: D33817119
fbshipit-source-id: 675d1e2fe468782da458832c2e88259c92951fdb
This commit is contained in:
committed by
Facebook GitHub Bot
parent
cb66520d55
commit
e686766e5f
@@ -82,7 +82,6 @@ export type SecureServerConfig = {
|
||||
* Flipper CA.
|
||||
*/
|
||||
export default class CertificateProvider {
|
||||
private didCertificateSetup = false;
|
||||
private server: ServerController;
|
||||
|
||||
constructor(server: ServerController) {
|
||||
@@ -127,9 +126,6 @@ export default class CertificateProvider {
|
||||
};
|
||||
|
||||
async certificateSetup() {
|
||||
if (this.didCertificateSetup) {
|
||||
return;
|
||||
}
|
||||
if (isTest()) {
|
||||
throw new Error('Server certificates not available in test');
|
||||
} else {
|
||||
@@ -138,7 +134,6 @@ export default class CertificateProvider {
|
||||
'ensureServerCertExists',
|
||||
);
|
||||
}
|
||||
this.didCertificateSetup = true;
|
||||
}
|
||||
|
||||
async processCertificateSigningRequest(
|
||||
@@ -155,7 +150,6 @@ export default class CertificateProvider {
|
||||
const rootFolder = await promisify(tmp.dir)();
|
||||
const certFolder = rootFolder + '/FlipperCerts/';
|
||||
const certsZipPath = rootFolder + '/certs.zip';
|
||||
await this.certificateSetup();
|
||||
const caCert = await this.getCACertificate();
|
||||
await this.deployOrStageFileForMobileApp(
|
||||
appDirectory,
|
||||
|
||||
Reference in New Issue
Block a user