mirror of
https://github.com/pocoproject/poco.git
synced 2025-02-22 23:11:00 +01:00
fixed GH #510: Incorrect RSAKey construction from istream
This commit is contained in:
parent
9258e482d7
commit
52ba87a6f0
@ -86,7 +86,9 @@ RSAKeyImpl::RSAKeyImpl(
|
||||
RSA* pubKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0);
|
||||
if (!pubKey)
|
||||
{
|
||||
int rc = BIO_seek(bio, 0);
|
||||
int rc = BIO_reset(bio);
|
||||
// BIO_reset() normally returns 1 for success and 0 or -1 for failure.
|
||||
// File BIOs are an exception, they return 0 for success and -1 for failure.
|
||||
if (rc != 0) throw Poco::FileException("Failed to load public key", publicKeyFile);
|
||||
pubKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, 0, 0);
|
||||
}
|
||||
@ -147,8 +149,10 @@ RSAKeyImpl::RSAKeyImpl(std::istream* pPublicKeyStream, std::istream* pPrivateKey
|
||||
RSA* publicKey = PEM_read_bio_RSAPublicKey(bio, &_pRSA, 0, 0);
|
||||
if (!publicKey)
|
||||
{
|
||||
int rc = BIO_seek(bio, 0);
|
||||
if (rc != 0) throw Poco::FileException("Failed to load public key");
|
||||
int rc = BIO_reset(bio);
|
||||
// BIO_reset() normally returns 1 for success and 0 or -1 for failure.
|
||||
// File BIOs are an exception, they return 0 for success and -1 for failure.
|
||||
if (rc != 1) throw Poco::FileException("Failed to load public key");
|
||||
publicKey = PEM_read_bio_RSA_PUBKEY(bio, &_pRSA, 0, 0);
|
||||
}
|
||||
BIO_free(bio);
|
||||
|
Loading…
x
Reference in New Issue
Block a user