From c1e6cd17b74411ac073a6bf6445cec973e6279be Mon Sep 17 00:00:00 2001 From: Yann Leboulanger Date: Thu, 19 Feb 2009 20:17:05 +0000 Subject: [PATCH] detect expires GPG keys. Fixes #4263 --- src/common/GnuPG.py | 2 ++ src/common/connection.py | 7 ++++++- src/gajim.py | 11 ++++++++++- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/common/GnuPG.py b/src/common/GnuPG.py index d19110f16..715ac7bf8 100644 --- a/src/common/GnuPG.py +++ b/src/common/GnuPG.py @@ -145,6 +145,8 @@ if gajim.HAVE_GPG: except IOError: pass if 'GOOD_PASSPHRASE' in resp or 'SIG_CREATED' in resp: return self._stripHeaderFooter(output) + if 'KEYEXPIRED' in resp: + return 'KEYEXPIRED' return 'BAD_PASSPHRASE' def verify(self, str_, sign): diff --git a/src/common/connection.py b/src/common/connection.py index c6679b35e..e1a4a2a08 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -964,13 +964,18 @@ class Connection(ConnectionHandlers): self.dispatch('SIGNED_IN', ()) def test_gpg_passphrase(self, password): + '''Returns 'ok', 'bad_pass' or 'expired' ''' if not self.gpg: return False self.gpg.passphrase = password keyID = gajim.config.get_per('accounts', self.name, 'keyid') signed = self.gpg.sign('test', keyID) 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): if gajim.config.get_per('accounts', self.name, 'gpg_sign_presence'): diff --git a/src/gajim.py b/src/gajim.py index d8930c0f1..86ae2d8b2 100644 --- a/src/gajim.py +++ b/src/gajim.py @@ -466,10 +466,19 @@ class PassphraseRequest: self.complete(None) 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 self.complete(passphrase) 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: # ask again