diff options
author | Maximilian Krambach <[email protected]> | 2018-08-23 09:28:18 +0000 |
---|---|---|
committer | Maximilian Krambach <[email protected]> | 2018-08-23 09:28:18 +0000 |
commit | 60dc499abd89f7e62a7b9cad943a96faa65187d5 (patch) | |
tree | cc1f69eb664256bdcead382339d28d61da27f55b /lang/js | |
parent | js: add decrypt result options (diff) | |
download | gpgme-60dc499abd89f7e62a7b9cad943a96faa65187d5.tar.gz gpgme-60dc499abd89f7e62a7b9cad943a96faa65187d5.zip |
js: update getDefaultKey to more precise logic
--
* src/Keyring.js: Adapted Keyring.getDefaultKey() to my current
understanding of a default signing key: either the default key set
in the gpg config, or 'the first usable private key' - usability
meaning 'not invalid, expired, revoked, and can be used for
signing'. It should be the same key used as in command line when
doing a --sign operation.
In case the user has a smartcard plugged in, we currently
won't know of this here, so our choice may differ. But as we do all
javascript-binding sign operations with the key fingerprint
explicitly set, this should not be a real problem. This method is
seen more as a convenience to tell using librarys which key
represents the main user.
Diffstat (limited to 'lang/js')
-rw-r--r-- | lang/js/src/Keyring.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lang/js/src/Keyring.js b/lang/js/src/Keyring.js index d6ba1d6f..d8fd8c81 100644 --- a/lang/js/src/Keyring.js +++ b/lang/js/src/Keyring.js @@ -221,7 +221,12 @@ export class GPGME_Keyring { reject(gpgme_error('KEY_NO_DEFAULT')); } else { for (let i=0; i< result.keys.length; i++ ) { - if (result.keys[i].invalid === false) { + if ( + result.keys[i].invalid === false && + result.keys[i].expired === false && + result.keys[i].revoked === false && + result.keys[i].can_sign === true + ) { let k = createKey( result.keys[i].fingerprint, !prepare_sync, |