From 733b68be2c15c401a248500bc9a2758cc99c899f Mon Sep 17 00:00:00 2001 From: Gilbert Chen Date: Wed, 11 Mar 2020 23:14:01 -0400 Subject: [PATCH] Do not take an RSA private key if the storage wasn't RSA encrypted. --- src/duplicacy_config.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/duplicacy_config.go b/src/duplicacy_config.go index 217bd4a..d2eef8f 100644 --- a/src/duplicacy_config.go +++ b/src/duplicacy_config.go @@ -588,6 +588,11 @@ func (config *Config) loadRSAPublicKey(keyFile string) { // loadRSAPrivateKey loads the specifed private key file for decrypting file chunks func (config *Config) loadRSAPrivateKey(keyFile string, passphrase string) { + if config.rsaPublicKey == nil { + LOG_ERROR("RSA_PUBLIC", "The storage was not encrypted by an RSA key") + return + } + encodedKey, err := ioutil.ReadFile(keyFile) if err != nil { LOG_ERROR("RSA_PRIVATE", "Failed to read the private key file: %v", err)