diff --git a/src/libsync/clientsideencryption.cpp b/src/libsync/clientsideencryption.cpp index 8c6f7ba748cb9..420e541bcefff 100644 --- a/src/libsync/clientsideencryption.cpp +++ b/src/libsync/clientsideencryption.cpp @@ -1325,13 +1325,11 @@ void ClientSideEncryption::generateKeyPair(const AccountPtr &account) return; } - auto privateKey = PKey::readPrivateKey(privKey); - qCDebug(lcCse()) << "Key correctly generated"; - auto csrOutput = generateCSR(account, std::move(localKeyPair), std::move(privateKey)); - writeMnemonic(account, [account, keyPair = std::move(csrOutput.second), output = std::move(csrOutput.first), this]() mutable -> void { - writeKeyPair(account, std::move(keyPair), output); + auto csrContent = generateCSR(account, std::move(localKeyPair), PKey::readPrivateKey(privKey)); + writeMnemonic(account, [account, keyPair = std::move(csrContent.second), csrContent = std::move(csrContent.first), this]() mutable -> void { + writeKeyPair(account, std::move(keyPair), csrContent); }); } @@ -1406,7 +1404,7 @@ std::pair ClientSideEncryption::generate void ClientSideEncryption::sendSignRequestCSR(const AccountPtr &account, PKey keyPair, - QByteArray csrContent) + const QByteArray &csrContent) { auto job = new SignPublicKeyApiJob(account, e2eeBaseUrl() + "public-key", this); job->setCsr(csrContent); @@ -1441,7 +1439,7 @@ void ClientSideEncryption::sendSignRequestCSR(const AccountPtr &account, void ClientSideEncryption::writeKeyPair(const AccountPtr &account, PKey keyPair, - QByteArray output) + const QByteArray &csrContent) { const auto privateKeyKeychainId = AbstractCredentials::keychainKey( account->url().toString(), @@ -1467,7 +1465,7 @@ void ClientSideEncryption::writeKeyPair(const AccountPtr &account, privateKeyJob->setInsecureFallback(false); privateKeyJob->setKey(privateKeyKeychainId); privateKeyJob->setBinaryData(bytearrayPrivateKey); - connect(privateKeyJob, &WritePasswordJob::finished, [keyPair = std::move(keyPair), publicKeyKeychainId, account, output, this] (Job *incoming) mutable { + connect(privateKeyJob, &WritePasswordJob::finished, [keyPair = std::move(keyPair), publicKeyKeychainId, account, csrContent, this] (Job *incoming) mutable { if (incoming->error() != Error::NoError) { failedToInitialize(account); return; @@ -1486,13 +1484,13 @@ void ClientSideEncryption::writeKeyPair(const AccountPtr &account, publicKeyJob->setInsecureFallback(false); publicKeyJob->setKey(publicKeyKeychainId); publicKeyJob->setBinaryData(bytearrayPublicKey); - connect(publicKeyJob, &WritePasswordJob::finished, [account, keyPair = std::move(keyPair), output, this](Job *incoming) mutable { + connect(publicKeyJob, &WritePasswordJob::finished, [account, keyPair = std::move(keyPair), csrContent, this](Job *incoming) mutable { if (incoming->error() != Error::NoError) { failedToInitialize(account); return; } - sendSignRequestCSR(account, std::move(keyPair), output); + sendSignRequestCSR(account, std::move(keyPair), csrContent); }); publicKeyJob->start(); }); diff --git a/src/libsync/clientsideencryption.h b/src/libsync/clientsideencryption.h index e95fc21bb44fb..a4a4c8be4f5ca 100644 --- a/src/libsync/clientsideencryption.h +++ b/src/libsync/clientsideencryption.h @@ -175,11 +175,11 @@ private slots: void sendSignRequestCSR(const AccountPtr &account, PKey keyPair, - QByteArray csrContent); + const QByteArray &csrContent); void writeKeyPair(const AccountPtr &account, PKey keyPair, - QByteArray output); + const QByteArray &csrContent); template void writeMnemonic(OCC::AccountPtr account,