mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-29 20:19:22 +03:00
Set S/MIME private key and certificate per identity #259
This commit is contained in:
parent
33de51b2d5
commit
6fa4dff23b
6 changed files with 83 additions and 35 deletions
|
|
@ -25,6 +25,9 @@ export class IdentityModel extends AbstractModel {
|
|||
pgpSign: false,
|
||||
pgpEncrypt: false,
|
||||
|
||||
smimeKey: '',
|
||||
smimeCertificate: '',
|
||||
|
||||
askDelete: false
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,20 @@ export class IdentityPopupView extends AbstractViewPopup {
|
|||
)
|
||||
);
|
||||
this.defaultOptionsAfterRender = defaultOptionsAfterRender;
|
||||
|
||||
this.createSelfSigned = this.createSelfSigned.bind(this);
|
||||
}
|
||||
|
||||
createSelfSigned() {
|
||||
let identity = this.identity();
|
||||
Remote.request('CreateSMimeCertificate', (iError, oData) => {
|
||||
if (oData.Result.x509) {
|
||||
identity.smimeKey(oData.Result.pkey);
|
||||
identity.smimeCertificate(oData.Result.x509);
|
||||
}
|
||||
}, {
|
||||
email: identity.email()
|
||||
});
|
||||
}
|
||||
|
||||
submitForm(form) {
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ trait SMime
|
|||
\RainLoop\Providers\Storage\Enumerations\StorageType::ROOT
|
||||
), '/') . '/.smime';
|
||||
*/
|
||||
$sEmail = $this->GetActionParam('Email', '') ?: $oAccount->Email();
|
||||
$sEmail = $this->GetActionParam('email', '') ?: $oAccount->Email();
|
||||
|
||||
$cert = new Certificate();
|
||||
$cert->distinguishedName['emailAddress'] = $sEmail;
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ trait User
|
|||
use Messages;
|
||||
use Attachments;
|
||||
use Pgp;
|
||||
// use SMime;
|
||||
use SMime;
|
||||
|
||||
private ?Suggestions $oSuggestionsProvider = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,8 +24,11 @@ class Identity implements \JsonSerializable
|
|||
|
||||
private bool $bSignatureInsertBefore = false;
|
||||
|
||||
private bool $bPgpEncrypt = false;
|
||||
private bool $bPgpSign = false;
|
||||
private bool $pgpEncrypt = false;
|
||||
private bool $pgpSign = false;
|
||||
|
||||
private string $SMimeKey = '';
|
||||
private string $SMimeCertificate = '';
|
||||
|
||||
function __construct(string $sId = '', string $sEmail = '')
|
||||
{
|
||||
|
|
@ -95,8 +98,10 @@ class Identity implements \JsonSerializable
|
|||
$this->sSignature = !empty($aData['Signature']) ? $aData['Signature'] : '';
|
||||
$this->bSignatureInsertBefore = !empty($aData['SignatureInsertBefore']);
|
||||
$this->sSentFolder = isset($aData['sentFolder']) ? $aData['sentFolder'] : '';
|
||||
$this->bPgpEncrypt = !empty($aData['pgpEncrypt']);
|
||||
$this->bPgpSign = !empty($aData['pgpSign']);
|
||||
$this->pgpEncrypt = !empty($aData['pgpEncrypt']);
|
||||
$this->pgpSign = !empty($aData['pgpSign']);
|
||||
$this->SMimeKey = isset($aData['smimeKey']) ? $aData['smimeKey'] : '';
|
||||
$this->SMimeCertificate = isset($aData['smimeCertificate']) ? $aData['smimeCertificate'] : '';
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -116,8 +121,10 @@ class Identity implements \JsonSerializable
|
|||
'Signature' => $this->sSignature,
|
||||
'SignatureInsertBefore' => $this->bSignatureInsertBefore,
|
||||
'sentFolder' => $this->sSentFolder,
|
||||
'pgpEncrypt' => $this->bPgpEncrypt,
|
||||
'pgpSign' => $this->bPgpSign
|
||||
'pgpEncrypt' => $this->pgpEncrypt,
|
||||
'pgpSign' => $this->pgpSign,
|
||||
'smimeKey' => $this->SMimeKey,
|
||||
'smimeCertificate' => $this->SMimeCertificate
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -135,8 +142,10 @@ class Identity implements \JsonSerializable
|
|||
'signature' => $this->sSignature,
|
||||
'signatureInsertBefore' => $this->bSignatureInsertBefore,
|
||||
'sentFolder' => $this->sSentFolder,
|
||||
'pgpEncrypt' => $this->bPgpEncrypt,
|
||||
'pgpSign' => $this->bPgpSign
|
||||
'pgpEncrypt' => $this->pgpEncrypt,
|
||||
'pgpSign' => $this->pgpSign,
|
||||
'smimeKey' => $this->SMimeKey,
|
||||
'smimeCertificate' => $this->SMimeCertificate
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,33 +55,55 @@
|
|||
<input type="radio" name="identitytabs" id="tab-identity-crypto">
|
||||
<label data-i18n="CONTACTS/TAB_CRYPTO" for="tab-identity-crypto" role="tab" aria-selected="false" aria-controls="panel3" tabindex="0"></label>
|
||||
<div class="form-horizontal tab-content" role="tabpanel" aria-hidden="false">
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
label: 'OPENPGP/LABEL_SIGN',
|
||||
value: pgpSign,
|
||||
name: 'pgpSign'
|
||||
}
|
||||
}"></div>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
label: 'OPENPGP/LABEL_ENCRYPT',
|
||||
value: pgpEncrypt,
|
||||
name: 'pgpEncrypt'
|
||||
}
|
||||
}"></div>
|
||||
<details>
|
||||
<summary><strong>PGP</strong></summary>
|
||||
<div class="control-group">
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
label: 'OPENPGP/LABEL_SIGN',
|
||||
value: pgpSign,
|
||||
name: 'pgpSign'
|
||||
}
|
||||
}"></div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
label: 'OPENPGP/LABEL_ENCRYPT',
|
||||
value: pgpEncrypt,
|
||||
name: 'pgpEncrypt'
|
||||
}
|
||||
}"></div>
|
||||
</div>
|
||||
<!--
|
||||
<div class="control-group">
|
||||
<label data-i18n="OPENPGP/LABEL_ENCRYPT"></label>
|
||||
<select name="PgpEncrypt" data-bind="value: pgpEncrypt">
|
||||
<option value="Ask" data-i18n="CONTACTS/ASK"></option>
|
||||
<option value="Never" data-i18n="CONTACTS/NEVER"></option>
|
||||
<option value="Always" data-i18n="CONTACTS/ALWAYS"></option>
|
||||
<option value="IfPossible" data-i18n="CONTACTS/ALWAYS_IF_POSSIBLE"></option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label data-i18n="OPENPGP/LABEL_ENCRYPT"></label>
|
||||
<select name="PgpEncrypt" data-bind="value: pgpEncrypt">
|
||||
<option value="Ask" data-i18n="CONTACTS/ASK"></option>
|
||||
<option value="Never" data-i18n="CONTACTS/NEVER"></option>
|
||||
<option value="Always" data-i18n="CONTACTS/ALWAYS"></option>
|
||||
<option value="IfPossible" data-i18n="CONTACTS/ALWAYS_IF_POSSIBLE"></option>
|
||||
</select>
|
||||
</div>
|
||||
-->
|
||||
</details>
|
||||
<details>
|
||||
<summary><strong>S/MIME</strong></summary>
|
||||
<div class="control-group">
|
||||
<label>Private key</label>
|
||||
<textarea name="smimeKey" class="input-xxlarge" rows="14" autofocus="" autocomplete="off" data-bind="value: smimeKey"></textarea>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label>Certificate</label>
|
||||
<textarea name="smimeCertificate" class="input-xxlarge" rows="14" autofocus="" autocomplete="off" data-bind="value: smimeCertificate"></textarea>
|
||||
</div>
|
||||
<div class="control-group" data-bind="hidden:smimeKey">
|
||||
<label></label>
|
||||
<button type="button" data-bind="click: $root.createSelfSigned">Create self-signed</button>
|
||||
</div>
|
||||
</details>
|
||||
</div>
|
||||
|
||||
<input type="radio" name="identitytabs" id="tab-identity-advanced">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue