mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-10 06:58:27 +03:00
Enable S/MIME encrypt #259
This commit is contained in:
parent
ca12655e5f
commit
e9a63b40c5
5 changed files with 15 additions and 17 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
|
|
@ -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-----')
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@
|
|||
<div id="mailvelope-settings" style="height:40em" data-bind="visible: canMailvelope"></div>
|
||||
</details>
|
||||
|
||||
<!-- TODO
|
||||
<details>
|
||||
<summary class="legend">S/MIME Certificates</summary>
|
||||
<table class="table table-hover list-table">
|
||||
|
|
@ -138,6 +137,7 @@
|
|||
<span data-i18n="CRYPTO/VALID_UNTIL"></span>:
|
||||
<time data-time-format="FULL" data-bind="time:validTo_time_t"></time>
|
||||
</td>
|
||||
<!-- TODO
|
||||
<td>
|
||||
<a class="btn btn-small btn-danger button-confirm-delete" data-bind="css: {'delete-access': askDelete()}, click: remove"
|
||||
data-i18n="GLOBAL/ARE_YOU_SURE"></a>
|
||||
|
|
@ -145,8 +145,8 @@
|
|||
<td>
|
||||
<span class="delete-key fontastic" data-bind="visible: !askDelete(), click: openForDeletion">🗑</span>
|
||||
</td>
|
||||
-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</details>
|
||||
-->
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue