diff --git a/src/common/connection.py b/src/common/connection.py index 53b20d645..654ec5198 100644 --- a/src/common/connection.py +++ b/src/common/connection.py @@ -1916,6 +1916,13 @@ class Connection: #Inform GUI we just signed in self.dispatch('SIGNED_IN', ()) + def test_gpg_passphrase(self, password): + 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' + def get_signed_msg(self, msg): signed = '' keyID = gajim.config.get_per('accounts', self.name, 'keyid') diff --git a/src/roster_window.py b/src/roster_window.py index 0a634eef7..8163404b2 100644 --- a/src/roster_window.py +++ b/src/roster_window.py @@ -1518,16 +1518,27 @@ _('If "%s" accepts this request you will know his or her status.') % jid) passphrase = self.gpg_passphrase[keyid] save = False else: - w = dialogs.PassphraseDialog( - _('Passphrase Required'), - _('Enter GPG key passphrase for account %s') % account, - _('Save passphrase')) - passphrase, save = w.run() - if passphrase == -1: - passphrase = None - else: - self.gpg_passphrase[keyid] = passphrase - gobject.timeout_add(30000, self.forget_gpg_passphrase, keyid) + password_ok = False + count = 0 + title = _('Passphrase Required') + second = _('Enter GPG key passphrase for account %s.') % \ + account + while not password_ok and count < 3: + count += 1 + w = dialogs.PassphraseDialog(title, second, + _('Save passphrase')) + passphrase, save = w.run() + if passphrase == -1: + passphrase = None + password_ok = True + else: + password_ok = gajim.connections[account].\ + test_gpg_passphrase(passphrase) + title = _('Wrong Passphrase') + second = _('Please retype your GPG passphrase or press Cancel.') + if passphrase != None: + self.gpg_passphrase[keyid] = passphrase + gobject.timeout_add(30000, self.forget_gpg_passphrase, keyid) if save: gajim.config.set_per('accounts', account, 'savegpgpass', True) gajim.config.set_per('accounts', account, 'gpgpassword',