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

APPLEMAIL-24 Release_2.1.0-RC0
Volker Birk 3 years ago
parent f7e3e02b70
commit ae18bf6a54
  1. 16
      downloadclient.cc
  2. 7
      downloadclient.hh

@ -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;
}

@ -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:

Loading…
Cancel
Save