Print out CSR mismatches when no matching one can be found
Summary: We're seeing some CSR mismatches when they aren't expected. Adding logging to print out what is being found, to see if it's any OS-specific encoding issues or something like that, or completely different CSRs, etc. URL encoded in case there are differences in non printable characters. Reviewed By: nikoant Differential Revision: D23867267 fbshipit-source-id: f406a396c808687b6b84561eb1def61b565aee34
This commit is contained in:
committed by
Facebook GitHub Bot
parent
a0d46bbb53
commit
390df577ae
@@ -373,15 +373,15 @@ export default class CertificateProvider {
|
|||||||
appName,
|
appName,
|
||||||
csr,
|
csr,
|
||||||
)
|
)
|
||||||
.then((isMatch) => {
|
.then((result) => {
|
||||||
return {id: device.id, isMatch, error: null};
|
return {id: device.id, ...result, error: null};
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
console.error(
|
console.error(
|
||||||
`Unable to check for matching CSR in ${device.id}:${appName}`,
|
`Unable to check for matching CSR in ${device.id}:${appName}`,
|
||||||
logTag,
|
logTag,
|
||||||
);
|
);
|
||||||
return {id: device.id, isMatch: false, error: e};
|
return {id: device.id, isMatch: false, foundCsr: null, error: e};
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
return Promise.all(deviceMatchList).then((devices) => {
|
return Promise.all(deviceMatchList).then((devices) => {
|
||||||
@@ -391,6 +391,16 @@ export default class CertificateProvider {
|
|||||||
if (erroredDevice) {
|
if (erroredDevice) {
|
||||||
throw erroredDevice.error;
|
throw erroredDevice.error;
|
||||||
}
|
}
|
||||||
|
const foundCsrs = devices
|
||||||
|
.filter((d) => d.foundCsr !== null)
|
||||||
|
.map((d) => (d.foundCsr ? encodeURI(d.foundCsr) : 'null'));
|
||||||
|
console.error(`Looking for CSR (url encoded):
|
||||||
|
|
||||||
|
${encodeURI(this.santitizeString(csr))}
|
||||||
|
|
||||||
|
Found these:
|
||||||
|
|
||||||
|
${foundCsrs.join('\n\n')}`);
|
||||||
throw new Error(`No matching device found for app: ${appName}`);
|
throw new Error(`No matching device found for app: ${appName}`);
|
||||||
}
|
}
|
||||||
if (matchingIds.length > 1) {
|
if (matchingIds.length > 1) {
|
||||||
@@ -445,7 +455,7 @@ export default class CertificateProvider {
|
|||||||
deviceId: string,
|
deviceId: string,
|
||||||
processName: string,
|
processName: string,
|
||||||
csr: string,
|
csr: string,
|
||||||
): Promise<boolean> {
|
): Promise<{isMatch: boolean; foundCsr: string}> {
|
||||||
return this.adb
|
return this.adb
|
||||||
.then((adbClient) =>
|
.then((adbClient) =>
|
||||||
androidUtil.pull(
|
androidUtil.pull(
|
||||||
@@ -458,10 +468,12 @@ export default class CertificateProvider {
|
|||||||
.then((deviceCsr) => {
|
.then((deviceCsr) => {
|
||||||
// Santitize both of the string before comparation
|
// Santitize both of the string before comparation
|
||||||
// The csr string extraction on client side return string in both way
|
// The csr string extraction on client side return string in both way
|
||||||
return (
|
const [sanitizedDeviceCsr, sanitizedClientCsr] = [
|
||||||
this.santitizeString(deviceCsr.toString()) ===
|
deviceCsr.toString(),
|
||||||
this.santitizeString(csr)
|
csr,
|
||||||
);
|
].map((s) => this.santitizeString(s));
|
||||||
|
const isMatch = sanitizedDeviceCsr === sanitizedClientCsr;
|
||||||
|
return {isMatch: isMatch, foundCsr: sanitizedDeviceCsr};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user