diff --git a/dev/App/User.js b/dev/App/User.js index ac473088a0..21d7b588b3 100644 --- a/dev/App/User.js +++ b/dev/App/User.js @@ -35,7 +35,7 @@ import { AccountUserStore } from 'Stores/User/Account'; import { ContactUserStore } from 'Stores/User/Contact'; import { FolderUserStore } from 'Stores/User/Folder'; import { PgpUserStore } from 'Stores/User/Pgp'; -//import { SMimeUserStore } from 'Stores/User/SMime'; +import { SMimeUserStore } from 'Stores/User/SMime'; import { MessagelistUserStore } from 'Stores/User/Messagelist'; import { ThemeStore, initThemes } from 'Stores/Theme'; import { LanguageStore } from 'Stores/Language'; @@ -217,8 +217,7 @@ export class AppUser extends AbstractApp { setInterval(reloadTime, 60000); PgpUserStore.init(); -// TODO: -// SMimeUserStore.loadCertificates(); + SMimeUserStore.loadCertificates(); setTimeout(() => mailToHelper(SettingsGet('mailToEmail')), 500); diff --git a/dev/Model/Identity.js b/dev/Model/Identity.js index 138463810c..ac46a15fef 100644 --- a/dev/Model/Identity.js +++ b/dev/Model/Identity.js @@ -1,5 +1,5 @@ import { AbstractModel } from 'Knoin/AbstractModel'; -import { addObservablesTo } from 'External/ko'; +import { addObservablesTo, addComputablesTo } from 'External/ko'; export class IdentityModel extends AbstractModel { /** @@ -30,6 +30,12 @@ export class IdentityModel extends AbstractModel { askDelete: false }); + + addComputablesTo(this, { + smimeKeyEncrypted: () => this.smimeKey().includes('-----BEGIN ENCRYPTED PRIVATE KEY-----') +// smimeKeyValid: () => this.smimeKeyEncrypted() | this.smimeKey().includes('-----BEGIN PRIVATE KEY-----') +// smimeCertificateValid: () => this.smimeKey().includes('-----BEGIN CERTIFICATE-----') + }); } /** diff --git a/dev/View/Popup/Compose.js b/dev/View/Popup/Compose.js index 45a09c8442..7bec4abdca 100644 --- a/dev/View/Popup/Compose.js +++ b/dev/View/Popup/Compose.js @@ -1400,6 +1400,7 @@ export class ComposePopupView extends AbstractViewPopup { || SMimeUserStore.find(certificate => email == certificate.emailAddress && certificate.smimeencrypt) ).length : 0; this.canSMimeEncrypt(length && length === count); + console.log({canSMimeEncrypt:this.canSMimeEncrypt()}); } async getMessageRequestParams(sSaveFolder, draft) @@ -1537,7 +1538,7 @@ export class ComposePopupView extends AbstractViewPopup { } else if (this.canSMimeSign()) { params.signCertificate = identity.smimeCertificate(); params.signPrivateKey = identity.smimeKey(); - if (identity.smimeKey().includes('-----BEGIN ENCRYPTED PRIVATE KEY-----')) { + if (identity.smimeKeyEncrypted()) { const pass = await AskPopupView.password('S/MIME private key', 'CRYPTO/SIGN'); params.signPassphrase = pass?.password; } diff --git a/dev/View/User/MailBox/MessageView.js b/dev/View/User/MailBox/MessageView.js index d4f997f066..ec15c8dfbd 100644 --- a/dev/View/User/MailBox/MessageView.js +++ b/dev/View/User/MailBox/MessageView.js @@ -623,14 +623,6 @@ export class MailMessageView extends AbstractViewRight { } async smimeDecrypt() { -/* - $sCertificate = $this->GetActionParam('signCertificate', ''); - $sPrivateKey = $this->GetActionParam('signPrivateKey', ''); - $sPassphrase = $this->GetActionParam('passphrase', ''); - - // TODO: find private key and certificate to decrypt - const oMessage = currentMessage(); -*/ const message = currentMessage(); let data = message.smimeEncrypted(); // { partId: "1" } const addresses = message.from.concat(message.to, message.cc, message.bcc).map(item => item.email), @@ -642,7 +634,7 @@ export class MailMessageView extends AbstractViewRight { // data.bodyPart = data.bodyPart?.raw; data.certificate = identity.smimeCertificate(); data.privateKey = identity.smimeKey(); - if (identity.smimeKey().includes('-----BEGIN ENCRYPTED PRIVATE KEY-----')) { + if (identity.smimeKeyEncrypted()) { const pass = await AskPopupView.password('S/MIME private key', 'CRYPTO/DECRYPT'); data.passphrase = pass?.password; } @@ -672,7 +664,7 @@ export class MailMessageView extends AbstractViewRight { message.html() ? message.viewHtml() : message.viewPlain(); response.Result.body = null; } - message.smimeVerified(response.Result); + message.smimeVerified(true); } }); } diff --git a/snappymail/v/0.0.0/app/templates/Views/User/SettingsSecurity.html b/snappymail/v/0.0.0/app/templates/Views/User/SettingsSecurity.html index 5df2dd5284..6c1b9b03fa 100644 --- a/snappymail/v/0.0.0/app/templates/Views/User/SettingsSecurity.html +++ b/snappymail/v/0.0.0/app/templates/Views/User/SettingsSecurity.html @@ -123,7 +123,6 @@
- --->