Only ask S/MIME private key passphrase when it is encrypted #259

This commit is contained in:
the-djmaze 2024-02-20 11:10:43 +01:00
parent f06b6edef5
commit f5f3a90275

View file

@ -1538,8 +1538,10 @@ export class ComposePopupView extends AbstractViewPopup {
} else if (this.canSMimeSign()) { } else if (this.canSMimeSign()) {
params.signCertificate = identity.smimeCertificate(); params.signCertificate = identity.smimeCertificate();
params.signPrivateKey = identity.smimeKey(); params.signPrivateKey = identity.smimeKey();
const pass = await AskPopupView.password('S/MIME key', 'CRYPTO/SIGN'); if (identity.smimeKey().includes('-----BEGIN ENCRYPTED PRIVATE KEY-----')) {
params.signPassphrase = pass?.password; const pass = await AskPopupView.password('S/MIME private key', 'CRYPTO/SIGN');
params.signPassphrase = pass?.password;
}
} }
} }
if (encrypt) { if (encrypt) {
@ -1555,7 +1557,7 @@ export class ComposePopupView extends AbstractViewPopup {
params.encryptFingerprints = JSON.stringify(GnuPGUserStore.getPublicKeyFingerprints(recipients)); params.encryptFingerprints = JSON.stringify(GnuPGUserStore.getPublicKeyFingerprints(recipients));
// } else { // } else {
// // S/MIME // // S/MIME
// params.encryptCertificates = ''; // params.encryptCertificates = [];
} else { } else {
throw 'Encryption with ' + encrypt + ' not yet implemented'; throw 'Encryption with ' + encrypt + ' not yet implemented';
} }