Fix SSH Agent broken decrypt button (#10638)

* SSH Agent: Fix broken decrypt button (Fixes #10637)

---------

Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
Alexandre Petit 2024-05-27 20:48:33 +02:00 committed by GitHub
parent 1fd8923746
commit 8cd45f57b7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 19 deletions

View File

@ -2556,10 +2556,6 @@ Disable safe saves and try again?</source>
<source>n/a</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>(encrypted)</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Select private key</source>
<translation type="unfinished"></translation>
@ -2669,6 +2665,10 @@ Would you like to correct it?</source>
<numerusform></numerusform>
</translation>
</message>
<message>
<source>Failed to decrypt SSH key, ensure password is correct.</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>EditEntryWidgetAdvanced</name>
@ -6204,6 +6204,10 @@ We recommend you use the AppImage available on our downloads page.</source>
<source>Unexpected EOF when writing private key</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>(encrypted)</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>OpenSSHKeyGenDialog</name>

View File

@ -661,23 +661,17 @@ void EditEntryWidget::updateSSHAgentKeyInfo()
if (!key.fingerprint().isEmpty()) {
m_sshAgentUi->fingerprintTextLabel->setText(key.fingerprint(QCryptographicHash::Md5) + "\n"
+ key.fingerprint(QCryptographicHash::Sha256));
} else {
m_sshAgentUi->fingerprintTextLabel->setText(tr("(encrypted)"));
}
if (!key.comment().isEmpty() || !key.encrypted()) {
if (!key.comment().isEmpty()) {
m_sshAgentUi->commentTextLabel->setText(key.comment());
} else {
m_sshAgentUi->commentTextLabel->setText(tr("(encrypted)"));
m_sshAgentUi->decryptButton->setEnabled(true);
}
m_sshAgentUi->decryptButton->setEnabled(key.encrypted());
if (!key.publicKey().isEmpty()) {
m_sshAgentUi->publicKeyEdit->document()->setPlainText(key.publicKey());
m_sshAgentUi->copyToClipboardButton->setEnabled(true);
} else {
m_sshAgentUi->publicKeyEdit->document()->setPlainText(tr("(encrypted)"));
m_sshAgentUi->copyToClipboardButton->setDisabled(true);
}
// enable agent buttons only if we have an agent running
@ -791,6 +785,7 @@ void EditEntryWidget::decryptPrivateKey()
OpenSSHKey key;
if (!getOpenSSHKey(key, true)) {
showMessage(tr("Failed to decrypt SSH key, ensure password is correct."), MessageWidget::Error);
return;
}
@ -804,6 +799,7 @@ void EditEntryWidget::decryptPrivateKey()
+ key.fingerprint(QCryptographicHash::Sha256));
m_sshAgentUi->publicKeyEdit->document()->setPlainText(key.publicKey());
m_sshAgentUi->copyToClipboardButton->setEnabled(true);
m_sshAgentUi->decryptButton->setEnabled(false);
}
void EditEntryWidget::copyPublicKey()

View File

@ -490,11 +490,7 @@ bool KeeAgentSettings::toOpenSSHKey(const QString& username,
}
if (key.comment().isEmpty()) {
key.setComment(username);
}
if (key.comment().isEmpty()) {
key.setComment(fileName);
key.setComment(QString("%1@%2").arg(username, fileName));
}
return true;

View File

@ -84,7 +84,7 @@ const QString OpenSSHKey::type() const
const QString OpenSSHKey::fingerprint(QCryptographicHash::Algorithm algo) const
{
if (m_rawPublicData.isEmpty()) {
return {};
return tr("(encrypted)");
}
QByteArray publicKey;
@ -351,6 +351,8 @@ bool OpenSSHKey::parsePKCS1PEM(const QByteArray& in)
// load private if no encryption
if (!encrypted()) {
return openKey();
} else {
m_comment = tr("(encrypted)");
}
return true;