Skip to content

Commit

Permalink
HttpCreds: Don't create empty client cert keychain entries #5752
Browse files Browse the repository at this point in the history
This doesn't do anything about deleting the client cert keychain
entries when the whole account is removed though.
  • Loading branch information
ckamm committed Nov 3, 2017
1 parent 354cdfd commit c9d5a9c
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 22 deletions.
46 changes: 26 additions & 20 deletions src/libsync/creds/httpcredentials.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,32 +442,38 @@ void HttpCredentials::persist()
_account->setCredentialSetting(QLatin1String(isOAuthC), isUsingOAuth());
_account->wantsAccountSaved(_account);

// write cert
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
addSettingsToJob(_account, job);
job->setInsecureFallback(false);
connect(job, &Job::finished, this, &HttpCredentials::slotWriteClientCertPEMJobDone);
job->setKey(keychainKey(_account->url().toString(), _user + clientCertificatePEMC, _account->id()));
job->setBinaryData(_clientSslCertificate.toPem());
job->start();
// write cert if there is one
if (!_clientSslCertificate.isNull()) {
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
addSettingsToJob(_account, job);
job->setInsecureFallback(false);
connect(job, &Job::finished, this, &HttpCredentials::slotWriteClientCertPEMJobDone);
job->setKey(keychainKey(_account->url().toString(), _user + clientCertificatePEMC, _account->id()));
job->setBinaryData(_clientSslCertificate.toPem());
job->start();
} else {
slotWriteClientCertPEMJobDone();
}
}

void HttpCredentials::slotWriteClientCertPEMJobDone(Job *incomingJob)
void HttpCredentials::slotWriteClientCertPEMJobDone()
{
Q_UNUSED(incomingJob);
// write ssl key
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
addSettingsToJob(_account, job);
job->setInsecureFallback(false);
connect(job, &Job::finished, this, &HttpCredentials::slotWriteClientKeyPEMJobDone);
job->setKey(keychainKey(_account->url().toString(), _user + clientKeyPEMC, _account->id()));
job->setBinaryData(_clientSslKey.toPem());
job->start();
// write ssl key if there is one
if (!_clientSslKey.isNull()) {
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
addSettingsToJob(_account, job);
job->setInsecureFallback(false);
connect(job, &Job::finished, this, &HttpCredentials::slotWriteClientKeyPEMJobDone);
job->setKey(keychainKey(_account->url().toString(), _user + clientKeyPEMC, _account->id()));
job->setBinaryData(_clientSslKey.toPem());
job->start();
} else {
slotWriteClientKeyPEMJobDone();
}
}

void HttpCredentials::slotWriteClientKeyPEMJobDone(Job *incomingJob)
void HttpCredentials::slotWriteClientKeyPEMJobDone()
{
Q_UNUSED(incomingJob);
WritePasswordJob *job = new WritePasswordJob(Theme::instance()->appName());
addSettingsToJob(_account, job);
job->setInsecureFallback(false);
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/creds/httpcredentials.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ private Q_SLOTS:
void slotReadClientKeyPEMJobDone(QKeychain::Job *);
void slotReadJobDone(QKeychain::Job *);

void slotWriteClientCertPEMJobDone(QKeychain::Job *);
void slotWriteClientKeyPEMJobDone(QKeychain::Job *);
void slotWriteClientCertPEMJobDone();
void slotWriteClientKeyPEMJobDone();
void slotWriteJobDone(QKeychain::Job *);

protected:
Expand Down

0 comments on commit c9d5a9c

Please sign in to comment.