Migrate CertificateProvider
Summary: _typescript_ Reviewed By: jknoxville Differential Revision: D16709300 fbshipit-source-id: ced6d2a40607f2eefe121463f47056e8e0e3b806
This commit is contained in:
committed by
Facebook Github Bot
parent
b292ecec71
commit
b60a3fcfe9
@@ -5,8 +5,8 @@
|
|||||||
* @format
|
* @format
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type {Logger} from '../fb-interfaces/Logger';
|
import {Logger} from '../fb-interfaces/Logger';
|
||||||
import Server from '../server.tsx';
|
import Server from '../server';
|
||||||
import {promisify} from 'util';
|
import {promisify} from 'util';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import {
|
import {
|
||||||
@@ -17,9 +17,9 @@ import path from 'path';
|
|||||||
import tmp from 'tmp';
|
import tmp from 'tmp';
|
||||||
const tmpFile = promisify(tmp.file);
|
const tmpFile = promisify(tmp.file);
|
||||||
const tmpDir = promisify(tmp.dir);
|
const tmpDir = promisify(tmp.dir);
|
||||||
import iosUtil from '../fb-stubs/iOSContainerUtility.tsx';
|
import iosUtil from '../fb-stubs/iOSContainerUtility';
|
||||||
import {reportPlatformFailures} from './metrics';
|
import {reportPlatformFailures} from './metrics';
|
||||||
import {getAdbClient} from './adbClient.tsx';
|
import {getAdbClient} from './adbClient';
|
||||||
import * as androidUtil from './androidContainerUtility';
|
import * as androidUtil from './androidContainerUtility';
|
||||||
|
|
||||||
// Desktop file paths
|
// Desktop file paths
|
||||||
@@ -48,13 +48,13 @@ const logTag = 'CertificateProvider';
|
|||||||
*/
|
*/
|
||||||
const x509SubjectCNRegex = /[=,]\s*CN=([^,]*)(,.*)?$/;
|
const x509SubjectCNRegex = /[=,]\s*CN=([^,]*)(,.*)?$/;
|
||||||
|
|
||||||
export type SecureServerConfig = {|
|
export type SecureServerConfig = {
|
||||||
key: Buffer,
|
key: Buffer;
|
||||||
cert: Buffer,
|
cert: Buffer;
|
||||||
ca: Buffer,
|
ca: Buffer;
|
||||||
requestCert: boolean,
|
requestCert: boolean;
|
||||||
rejectUnauthorized: boolean,
|
rejectUnauthorized: boolean;
|
||||||
|};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This class is responsible for generating and deploying server and client
|
* This class is responsible for generating and deploying server and client
|
||||||
@@ -87,7 +87,7 @@ export default class CertificateProvider {
|
|||||||
unsanitizedCsr: string,
|
unsanitizedCsr: string,
|
||||||
os: string,
|
os: string,
|
||||||
appDirectory: string,
|
appDirectory: string,
|
||||||
): Promise<{|deviceId: string|}> {
|
): Promise<{deviceId: string}> {
|
||||||
const csr = this.santitizeString(unsanitizedCsr);
|
const csr = this.santitizeString(unsanitizedCsr);
|
||||||
if (csr === '') {
|
if (csr === '') {
|
||||||
return Promise.reject(new Error(`Received empty CSR from ${os} device`));
|
return Promise.reject(new Error(`Received empty CSR from ${os} device`));
|
||||||
@@ -408,7 +408,7 @@ export default class CertificateProvider {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.then(subject => {
|
.then((subject: string) => {
|
||||||
const matches = subject.trim().match(x509SubjectCNRegex);
|
const matches = subject.trim().match(x509SubjectCNRegex);
|
||||||
if (!matches || matches.length < 2) {
|
if (!matches || matches.length < 2) {
|
||||||
throw new Error(`Cannot extract CN from ${subject}`);
|
throw new Error(`Cannot extract CN from ${subject}`);
|
||||||
Reference in New Issue
Block a user