detect expires GPG keys. Fixes #4263
This commit is contained in:
parent
0724a4ffea
commit
c1e6cd17b7
|
@ -145,6 +145,8 @@ if gajim.HAVE_GPG:
|
||||||
except IOError: pass
|
except IOError: pass
|
||||||
if 'GOOD_PASSPHRASE' in resp or 'SIG_CREATED' in resp:
|
if 'GOOD_PASSPHRASE' in resp or 'SIG_CREATED' in resp:
|
||||||
return self._stripHeaderFooter(output)
|
return self._stripHeaderFooter(output)
|
||||||
|
if 'KEYEXPIRED' in resp:
|
||||||
|
return 'KEYEXPIRED'
|
||||||
return 'BAD_PASSPHRASE'
|
return 'BAD_PASSPHRASE'
|
||||||
|
|
||||||
def verify(self, str_, sign):
|
def verify(self, str_, sign):
|
||||||
|
|
|
@ -964,13 +964,18 @@ class Connection(ConnectionHandlers):
|
||||||
self.dispatch('SIGNED_IN', ())
|
self.dispatch('SIGNED_IN', ())
|
||||||
|
|
||||||
def test_gpg_passphrase(self, password):
|
def test_gpg_passphrase(self, password):
|
||||||
|
'''Returns 'ok', 'bad_pass' or 'expired' '''
|
||||||
if not self.gpg:
|
if not self.gpg:
|
||||||
return False
|
return False
|
||||||
self.gpg.passphrase = password
|
self.gpg.passphrase = password
|
||||||
keyID = gajim.config.get_per('accounts', self.name, 'keyid')
|
keyID = gajim.config.get_per('accounts', self.name, 'keyid')
|
||||||
signed = self.gpg.sign('test', keyID)
|
signed = self.gpg.sign('test', keyID)
|
||||||
self.gpg.password = None
|
self.gpg.password = None
|
||||||
return signed != 'BAD_PASSPHRASE'
|
if signed == 'KEYEXPIRED':
|
||||||
|
return 'expired'
|
||||||
|
elif signed == 'BAD_PASSPHRASE':
|
||||||
|
return 'bad_pass'
|
||||||
|
return 'ok'
|
||||||
|
|
||||||
def get_signed_presence(self, msg, callback = None):
|
def get_signed_presence(self, msg, callback = None):
|
||||||
if gajim.config.get_per('accounts', self.name, 'gpg_sign_presence'):
|
if gajim.config.get_per('accounts', self.name, 'gpg_sign_presence'):
|
||||||
|
|
11
src/gajim.py
11
src/gajim.py
|
@ -466,10 +466,19 @@ class PassphraseRequest:
|
||||||
self.complete(None)
|
self.complete(None)
|
||||||
|
|
||||||
def _ok(passphrase, checked, count):
|
def _ok(passphrase, checked, count):
|
||||||
if gajim.connections[account].test_gpg_passphrase(passphrase):
|
result = gajim.connections[account].test_gpg_passphrase(passphrase)
|
||||||
|
if result == 'ok':
|
||||||
# passphrase is good
|
# passphrase is good
|
||||||
self.complete(passphrase)
|
self.complete(passphrase)
|
||||||
return
|
return
|
||||||
|
elif result == 'expired':
|
||||||
|
dialogs.ErrorDialog(_('GPG key expired'),
|
||||||
|
_('Your GPG key has expied, you will be connected to %s without '
|
||||||
|
'OpenPGP.') % account)
|
||||||
|
# Don't try to connect with GPG
|
||||||
|
gajim.connections[account].continue_connect_info[2] = False
|
||||||
|
self.complete(None)
|
||||||
|
return
|
||||||
|
|
||||||
if count < 3:
|
if count < 3:
|
||||||
# ask again
|
# ask again
|
||||||
|
|
Loading…
Reference in New Issue