diff --git a/identitymanager.cpp b/identitymanager.cpp index bd8220dd..303ac29e 100644 --- a/identitymanager.cpp +++ b/identitymanager.cpp @@ -110,6 +110,10 @@ IdentityManager::IdentityManager(QDir directory) BIO_free(biokey); 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"; } diff --git a/nvpairingmanager.cpp b/nvpairingmanager.cpp index 5947df47..91a12baf 100644 --- a/nvpairingmanager.cpp +++ b/nvpairingmanager.cpp @@ -29,9 +29,9 @@ NvPairingManager::NvPairingManager(QString address, IdentityManager im) : bio = BIO_new_mem_buf(pk.data(), -1); 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); - if (m_Cert == nullptr) + if (m_PrivateKey == nullptr) { throw new std::runtime_error("Unable to load private key"); }