forked from pEp.foundation/downloadclient
be sure to use the keyfile readonly and transport the real exception
parent
f7e3e02b70
commit
ae18bf6a54
|
@ -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…
Reference in New Issue