问题
I'm working on a JS script (ru that will upload an app to intune. When I try to commit an app content file to intune I always receive commitFileFailed, and I don't see any reason for that. Is there any way to figure out why it fails?
I think it may be because of the encryption, but I'm not really sure. This is how I encrypted it:
const key = Crypto.randomBytes(32);
const hmacKey = Crypto.randomBytes(32);
const iv = Crypto.randomBytes(16);
const cipher = Crypto.createCipheriv('aes256', key, iv);
const hmac = Crypto.createHmac('sha256', hmacKey);
const hash = Crypto.createHash('sha256');
let encrypted = cipher.update(originalFileBuffer);
encrypted = [...encrypted, ...cipher.final()];
const encryptedBuffer = Buffer.from(encrypted);
let encryptedHmac = hmac.update(encryptedBuffer);
let digest = hmac.digest('base64');
hash.update(Buffer.from(originalFileBuffer));
const fileDigest = hash.digest('base64');
const encryptionInfo = {
fileEncryptionInfo: {
'@odata.type': 'microsoft.graph.fileEncryptionInfo',
encryptionKey: Buffer.from(key).toString('base64'),
macKey: Buffer.from(hmacKey).toString('base64'),
initializationVector: Buffer.from(iv).toString('base64'),
mac: digest,
profileIdentifier: 'ProfileVersion1',
fileDigest: fileDigest,
fileDigestAlgorithm: 'SHA256'
}
};
And my encryption info looks like this:
{
"encryptionKey": "5hYywG3rkdeMLSuvW6xyvA==",
"macKey": "0PVu0l0avph6p2E3HCpHIw==",
"initializationVector": "UQVtvxe4n28oWrMLz5ei9w==",
"mac": "hjD5yZnOPFJjgijB4vtdw+6Lh8U3X2Xnp8dOcscv/QI=",
"profileIdentifier": "ProfileVersion1",
"fileDigest": "wMlT8MU7Rm0BXzIj8STRCjjye/Hn0UQTqQ9A2eRb41U=",
"fileDigestAlgorithm": "SHA256"
}
And the manifest like this:
<?xml version="1.0" encoding="utf-8"?>
<AndroidManifestProperties xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Package>test.android.app</Package>
<PackageVersionCode>1</PackageVersionCode>
<PackageVersionName>1.0.0</PackageVersionName>
<ApplicationName>TestApp.apk</ApplicationName>
<MinSdkVersion>4</MinSdkVersion>
<AWTVersion/>
</AndroidManifestProperties>
Any help would be appreciated. Thanks.
来源:https://stackoverflow.com/questions/51919573/commitfilefailed-during-mobileappcontentfile-commit