be sure to use the keyfile readonly and transport the real exception

APPLEMAIL-24 Release_2.1.0-RC0
Volker Birk 2020-06-11 12:41:28 +02:00
parent f7e3e02b70
commit ae18bf6a54
2 changed files with 6 additions and 17 deletions

View File

@ -11,17 +11,13 @@ namespace pEp {
PublicKey load_key(string filename)
{
CryptoPP::RSA::PublicKey key;
std::ifstream ifs{filename, std::ios::binary};
try {
CryptoPP::ByteQueue queue;
CryptoPP::FileSource file(filename.c_str(), true);
file.TransferTo(queue);
queue.MessageEnd();
key.Load(queue);
}
catch (exception&) {
throw CannotLoadKey(filename);
}
CryptoPP::ByteQueue queue;
CryptoPP::FileSource file(ifs, true);
file.TransferTo(queue);
queue.MessageEnd();
key.Load(queue);
return key;
}

View File

@ -14,13 +14,6 @@ namespace pEp {
DownloadError() : runtime_error("download not possible") { }
};
struct CannotLoadKey : runtime_error {
CannotLoadKey(string filename)
: runtime_error("cannot load key from " + filename)
{
}
};
// load_key() - load BER encoded RSA public key
//
// params: