Add verbose logging for Android cert exchange
Reviewed By: lblasa Differential Revision: D40981864 fbshipit-source-id: f99f517c5abdce839a441c21d50ce8488b249313
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2c767e1920
commit
7e9166137c
@@ -27,12 +27,24 @@ export default class AndroidCertificateProvider extends CertificateProvider {
|
|||||||
appDirectory: string,
|
appDirectory: string,
|
||||||
csr: string,
|
csr: string,
|
||||||
): Promise<string> {
|
): Promise<string> {
|
||||||
|
console.debug(
|
||||||
|
'AndroidCertificateProvider.getTargetDeviceId',
|
||||||
|
appName,
|
||||||
|
appDirectory,
|
||||||
|
csr,
|
||||||
|
);
|
||||||
const devicesInAdb = await this.adb.listDevices();
|
const devicesInAdb = await this.adb.listDevices();
|
||||||
if (devicesInAdb.length === 0) {
|
if (devicesInAdb.length === 0) {
|
||||||
throw new Error('No Android devices found');
|
throw new Error('No Android devices found');
|
||||||
}
|
}
|
||||||
const deviceMatchList = devicesInAdb.map(async (device) => {
|
const deviceMatchList = devicesInAdb.map(async (device) => {
|
||||||
try {
|
try {
|
||||||
|
console.debug(
|
||||||
|
'AndroidCertificateProvider.getTargetDeviceId -> matching device',
|
||||||
|
device.id,
|
||||||
|
appName,
|
||||||
|
appDirectory,
|
||||||
|
);
|
||||||
const result = await this.androidDeviceHasMatchingCSR(
|
const result = await this.androidDeviceHasMatchingCSR(
|
||||||
appDirectory,
|
appDirectory,
|
||||||
device.id,
|
device.id,
|
||||||
@@ -112,6 +124,14 @@ export default class AndroidCertificateProvider extends CertificateProvider {
|
|||||||
deviceCsr.toString(),
|
deviceCsr.toString(),
|
||||||
csr,
|
csr,
|
||||||
].map((s) => this.santitizeString(s));
|
].map((s) => this.santitizeString(s));
|
||||||
|
console.debug(
|
||||||
|
'AndroidCertificateProvider.androidDeviceHasMatchingCSR',
|
||||||
|
directory,
|
||||||
|
deviceId,
|
||||||
|
processName,
|
||||||
|
sanitizedDeviceCsr,
|
||||||
|
sanitizedClientCsr,
|
||||||
|
);
|
||||||
const isMatch = sanitizedDeviceCsr === sanitizedClientCsr;
|
const isMatch = sanitizedDeviceCsr === sanitizedClientCsr;
|
||||||
return {isMatch: isMatch, foundCsr: sanitizedDeviceCsr};
|
return {isMatch: isMatch, foundCsr: sanitizedDeviceCsr};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,19 +33,45 @@ export default abstract class CertificateProvider {
|
|||||||
os: string,
|
os: string,
|
||||||
appDirectory: string,
|
appDirectory: string,
|
||||||
): Promise<{deviceId: string}> {
|
): Promise<{deviceId: string}> {
|
||||||
|
console.debug(
|
||||||
|
`${this.constructor.name}.processCertificateSigningRequest`,
|
||||||
|
unsanitizedCsr,
|
||||||
|
os,
|
||||||
|
appDirectory,
|
||||||
|
);
|
||||||
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`));
|
||||||
}
|
}
|
||||||
|
console.debug(
|
||||||
|
`${this.constructor.name}.processCertificateSigningRequest -> ensureOpenSSLIsAvailable`,
|
||||||
|
os,
|
||||||
|
appDirectory,
|
||||||
|
);
|
||||||
await ensureOpenSSLIsAvailable();
|
await ensureOpenSSLIsAvailable();
|
||||||
const caCert = await getCACertificate();
|
const caCert = await getCACertificate();
|
||||||
|
console.debug(
|
||||||
|
`${this.constructor.name}.processCertificateSigningRequest -> deploy caCert`,
|
||||||
|
os,
|
||||||
|
appDirectory,
|
||||||
|
);
|
||||||
await this.deployOrStageFileForDevice(
|
await this.deployOrStageFileForDevice(
|
||||||
appDirectory,
|
appDirectory,
|
||||||
deviceCAcertFile,
|
deviceCAcertFile,
|
||||||
caCert,
|
caCert,
|
||||||
csr,
|
csr,
|
||||||
);
|
);
|
||||||
|
console.debug(
|
||||||
|
`${this.constructor.name}.processCertificateSigningRequest -> generateClientCertificate`,
|
||||||
|
os,
|
||||||
|
appDirectory,
|
||||||
|
);
|
||||||
const clientCert = await generateClientCertificate(csr);
|
const clientCert = await generateClientCertificate(csr);
|
||||||
|
console.debug(
|
||||||
|
`${this.constructor.name}.processCertificateSigningRequest -> deploy clientCert`,
|
||||||
|
os,
|
||||||
|
appDirectory,
|
||||||
|
);
|
||||||
await this.deployOrStageFileForDevice(
|
await this.deployOrStageFileForDevice(
|
||||||
appDirectory,
|
appDirectory,
|
||||||
deviceClientCertFile,
|
deviceClientCertFile,
|
||||||
@@ -53,7 +79,20 @@ export default abstract class CertificateProvider {
|
|||||||
csr,
|
csr,
|
||||||
);
|
);
|
||||||
const appName = await extractAppNameFromCSR(csr);
|
const appName = await extractAppNameFromCSR(csr);
|
||||||
|
console.debug(
|
||||||
|
`${this.constructor.name}.processCertificateSigningRequest -> getTargetDeviceId`,
|
||||||
|
os,
|
||||||
|
appDirectory,
|
||||||
|
appName,
|
||||||
|
);
|
||||||
const deviceId = await this.getTargetDeviceId(appName, appDirectory, csr);
|
const deviceId = await this.getTargetDeviceId(appName, appDirectory, csr);
|
||||||
|
console.debug(
|
||||||
|
`${this.constructor.name}.processCertificateSigningRequest -> done`,
|
||||||
|
os,
|
||||||
|
appDirectory,
|
||||||
|
appName,
|
||||||
|
deviceId,
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
deviceId,
|
deviceId,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user