mirror of
https://github.com/nextcloud/desktop.git
synced 2024-12-13 17:38:32 +03:00
[CSE] Fix reading the public key for the metadata
This broke when we started to use QSslKey and the Qt Keychain framework.
This commit is contained in:
parent
a08a32ceca
commit
0a83d3e743
2 changed files with 5 additions and 9 deletions
|
@ -1134,16 +1134,12 @@ FolderMetadata::FolderMetadata(AccountPtr account, const QByteArray& metadata) :
|
|||
|
||||
// RSA/ECB/OAEPWithSHA-256AndMGF1Padding using private / public key.
|
||||
QByteArray FolderMetadata::encryptMetadataKeys(const nlohmann::json& metadataKeys) const {
|
||||
auto path = publicKeyPath(_account);
|
||||
const char *pathC = qPrintable(path);
|
||||
|
||||
FILE* pkeyFile = fopen(pathC, "r");
|
||||
if (!pkeyFile) {
|
||||
qCInfo(lcCse()) << "Could not open the public key";
|
||||
exit(1);
|
||||
}
|
||||
BIO *publicKeyBio = BIO_new(BIO_s_mem());
|
||||
QByteArray publicKeyPem = _account->e2e()->_publicKey.toPem();
|
||||
BIO_write(publicKeyBio, publicKeyPem.constData(), publicKeyPem.size());
|
||||
|
||||
EVP_PKEY *key = PEM_read_PUBKEY(pkeyFile, NULL, NULL, NULL);
|
||||
EVP_PKEY *key = PEM_read_bio_PUBKEY(publicKeyBio, NULL, NULL, NULL);
|
||||
|
||||
auto data = QByteArray::fromStdString(metadataKeys.dump());
|
||||
auto ret = EncryptionHelper::encryptStringAsymmetric(key, data);
|
||||
|
|
|
@ -42,7 +42,6 @@ public:
|
|||
void encryptPrivateKey();
|
||||
void setTokenForFolder(const QByteArray& folder, const QByteArray& token);
|
||||
QByteArray tokenForFolder(const QByteArray& folder) const;
|
||||
|
||||
void fetchFolderEncryptedStatus();
|
||||
|
||||
// to be used together with FolderStatusModel::FolderInfo::_path.
|
||||
|
@ -77,6 +76,7 @@ private:
|
|||
QMap<QByteArray, QByteArray> _folder2token;
|
||||
QMap<QString, bool> _folder2encryptedStatus;
|
||||
|
||||
public:
|
||||
QSslKey _privateKey;
|
||||
QSslKey _publicKey;
|
||||
QSslCertificate _certificate;
|
||||
|
|
Loading…
Reference in a new issue