mirror of
https://github.com/cryptomator/cryptomator.git
synced 2026-05-14 08:41:28 +00:00
Merge pull request #4180 from cryptomator/feature/patched-masterkey-loading
don't load masterkey from arbitrary paths
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package org.cryptomator.ui.keyloading.masterkeyfile;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.cryptomator.common.Constants;
|
||||
import org.cryptomator.common.Passphrase;
|
||||
import org.cryptomator.common.keychain.KeychainManager;
|
||||
import org.cryptomator.common.vaults.Vault;
|
||||
@@ -63,16 +64,21 @@ public class MasterkeyFileLoadingStrategy implements KeyLoadingStrategy {
|
||||
public Masterkey loadKey(URI keyId) throws MasterkeyLoadingFailedException {
|
||||
window.setTitle(resourceBundle.getString("unlock.title").formatted(vault.getDisplayName()));
|
||||
Preconditions.checkArgument(SCHEME.equalsIgnoreCase(keyId.getScheme()), "Only supports keys with scheme " + SCHEME);
|
||||
if (!Constants.MASTERKEY_FILENAME.equals(keyId.getSchemeSpecificPart())) {
|
||||
LOG.warn("unsupported masterkey path found in vault.cryptomator: {}", keyId.getSchemeSpecificPart());
|
||||
}
|
||||
try {
|
||||
Path filePath = vault.getPath().resolve(keyId.getSchemeSpecificPart());
|
||||
// determine masterkey file path:
|
||||
Path filePath = vault.getPath().resolve(Constants.MASTERKEY_FILENAME);
|
||||
if (!Files.exists(filePath)) {
|
||||
filePath = askUserForMasterkeyFilePath();
|
||||
}
|
||||
// unlock:
|
||||
if (passphrase == null) {
|
||||
askForPassphrase();
|
||||
}
|
||||
var masterkey = masterkeyFileAccess.load(filePath, passphrase);
|
||||
//backup
|
||||
// backup on successful unlock:
|
||||
if (filePath.startsWith(vault.getPath())) {
|
||||
try {
|
||||
BackupHelper.attemptBackup(filePath);
|
||||
|
||||
Reference in New Issue
Block a user