{"record":{"id":"31ae8d10dbf083b8","repo":"MuntashirAkon/AppManager","slug":"could-not-verify-keystore-files-nfile-file-getname-nfound","errorCode":null,"errorMessage":"Could not verify KeyStore files.\\nFile: \" + file.getName() + \"\\nFound: \" + checksum + \"\\nRequired: \" + mChecksum.get(file.getName())","messagePattern":"Could not verify KeyStore files\\.\\\\nFile: \" \\+ file\\.getName\\(\\) \\+ \"\\\\nFound: \" \\+ checksum \\+ \"\\\\nRequired: \" \\+ mChecksum\\.get\\(file\\.getName\\(\\)\\)","errorType":"exception","errorClass":"BackupException","httpStatus":null,"severity":"error","filePath":"app/src/main/java/io/github/muntashirakon/AppManager/backup/VerifyOp.java","lineNumber":167,"sourceCode":"                throw new BackupException(\"Could not verify APK files.\" +\n                        \"\\nFile: \" + file.getName() +\n                        \"\\nFound: \" + checksum +\n                        \"\\nRequired: \" + mChecksum.get(file.getName()));\n            }\n        }\n    }\n\n    private void verifyKeyStore() throws BackupException {\n        Path[] keyStoreFiles = mBackupItem.getKeyStoreFiles();\n        if (keyStoreFiles.length == 0) {\n            // Not having KeyStore backups is fine.\n            return;\n        }\n        String checksum;\n        for (Path file : keyStoreFiles) {\n            checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, file);\n            if (!checksum.equals(mChecksum.get(file.getName()))) {\n                throw new BackupException(\"Could not verify KeyStore files.\" +\n                        \"\\nFile: \" + file.getName() +\n                        \"\\nFound: \" + checksum +\n                        \"\\nRequired: \" + mChecksum.get(file.getName()));\n            }\n        }\n    }\n\n    private void verifyData() throws BackupException {\n        Path[] dataFiles;\n        String checksum;\n        for (int i = 0; i < mBackupMetadata.dataDirs.length; ++i) {\n            dataFiles = mBackupItem.getDataFiles(i);\n            if (dataFiles.length == 0) {\n                throw new BackupException(\"No data files at index \" + i + \".\");\n            }\n            for (Path file : dataFiles) {\n                checksum = DigestUtils.getHexDigest(mBackupInfo.checksumAlgo, file);\n                if (!checksum.equals(mChecksum.get(file.getName()))) {","sourceCodeStart":149,"sourceCodeEnd":185,"githubUrl":"https://github.com/MuntashirAkon/AppManager/blob/0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5/app/src/main/java/io/github/muntashirakon/AppManager/backup/VerifyOp.java#L149-L185","documentation":"A KeyStore backup file (backed-up credential/key store included when mBackupMetadata.keyStore is true) fails checksum verification: its computed digest differs from the digest in the checksum file. Since KeyStore material is security-sensitive, App Manager refuses to proceed when it doesn't match.","triggerScenarios":"verify() -> verifyKeyStore(), called only when mBackupFlags.backupData() and mBackupMetadata.keyStore are set; any file from mBackupItem.getKeyStoreFiles() whose DigestUtils digest != mChecksum.get(file.getName()); zero KeyStore files is OK (returns early) — only an existing-but-mismatching file throws.","commonSituations":"KeyStore backup file modified or truncated while moving the backup between devices/storage; merging backups mixed files from different runs; key store bytes differ across devices making hand-copied backup sets inconsistent; checksum file missing the key store entry (null required).","solutions":["Re-copy the KeyStore backup file from the original backup; do not attempt to patch it manually.","Recreate the backup including KeyStore data so files and checksums are regenerated together.","If KeyStore backup is not needed, recreate the backup with the KeyStore option disabled.","Check that the checksum file is from the same backup run as the key store file."],"exampleFix":"// before\n//   Could not verify KeyStore files. File: keystore.tar.gz Found: ... Required: ...\n// after: restore original keystore backup file or re-run backup with KeyStore enabled","handlingStrategy":"validation","validationCode":"// Pre-check KeyStore files when metadata.keyStore is true\nif (metadata.keyStore) {\n    for (Path ks : backupItem.getKeyStoreFiles()) {\n        if (!DigestUtils.getHexDigest(backupInfo.checksumAlgo, ks).equals(checksums.get(ks.getName()))) {\n            throw new IllegalStateException(\"KeyStore backup corrupt: \" + ks.getName());\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    verifyOp.verify();\n} catch (BackupException e) {\n    if (e.getMessage().startsWith(\"Could not verify KeyStore files\")) {\n        // treat as security-relevant: restore from original backup, never patch manually\n    }\n}","preventionTips":["Copy KeyStore backup files only via byte-exact methods; never open/resave them.","Recreate the backup instead of merging key store files from different runs.","Disable the KeyStore backup option if the credential data is not needed for restore.","Verify on the source device before wiping or transferring."],"tags":["backup","keystore","integrity","checksum"],"backgroundTag":"checksum-mismatch","analyzedSha":"0152f468fc9463ee02dc2ca83f6fe4989a2c4ca5","analyzedAt":"2026-09-12T14:03:37.243Z","contentChangedAt":"2026-09-12T14:03:37.243Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}