mirror of
https://github.com/moonlight-stream/moonlight-qt
synced 2024-11-10 05:34:17 +00:00
Fix PEM reading issues and assert to catch generating corrupt keypairs
This commit is contained in:
parent
9bd804c4c3
commit
d4689b466a
2 changed files with 6 additions and 2 deletions
|
@ -110,6 +110,10 @@ IdentityManager::IdentityManager(QDir directory)
|
||||||
BIO_free(biokey);
|
BIO_free(biokey);
|
||||||
BIO_free(biocert);
|
BIO_free(biocert);
|
||||||
|
|
||||||
|
// Ensure we can actually consume the keys we just wrote
|
||||||
|
assert(!QSslCertificate(m_CachedPemCert).isNull());
|
||||||
|
assert(!QSslKey(m_CachedPrivateKey, QSsl::Rsa).isNull());
|
||||||
|
|
||||||
qDebug() << "Wrote new identity credentials to disk";
|
qDebug() << "Wrote new identity credentials to disk";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,9 +29,9 @@ NvPairingManager::NvPairingManager(QString address, IdentityManager im) :
|
||||||
bio = BIO_new_mem_buf(pk.data(), -1);
|
bio = BIO_new_mem_buf(pk.data(), -1);
|
||||||
THROW_BAD_ALLOC_IF_NULL(bio);
|
THROW_BAD_ALLOC_IF_NULL(bio);
|
||||||
|
|
||||||
PEM_read_bio_PrivateKey(bio, &m_PrivateKey, nullptr, nullptr);
|
m_PrivateKey = PEM_read_bio_PrivateKey(bio, nullptr, nullptr, nullptr);
|
||||||
BIO_free_all(bio);
|
BIO_free_all(bio);
|
||||||
if (m_Cert == nullptr)
|
if (m_PrivateKey == nullptr)
|
||||||
{
|
{
|
||||||
throw new std::runtime_error("Unable to load private key");
|
throw new std::runtime_error("Unable to load private key");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue