Commit 34248839 authored by Yann Leboulanger's avatar Yann Leboulanger

ability to see certificate information when fingerprint changes. see #3998

parent 86e940e7
......@@ -1281,7 +1281,7 @@ def connection_accepted(self, con, con_type):
# Check sha1 fingerprint
if con.Connection.ssl_fingerprint_sha1 != saved_fingerprint:
gajim.nec.push_incoming_event(FingerprintErrorEvent(None,
conn=self,
conn=self, certificate=con.Connection.ssl_certificate,
new_fingerprint=con.Connection.ssl_fingerprint_sha1))
return True
else:
......
......@@ -449,6 +449,7 @@ def _ssl_verify_callback(self, sslconn, cert, errnum, depth, ok):
# Exceptions can't propagate up through this callback, so print them here.
try:
self._owner.ssl_fingerprint_sha1 = cert.digest('sha1')
self._owner.ssl_certificate = cert
if errnum == 0:
return True
self._owner.ssl_errnum = errnum
......
......@@ -5606,3 +5606,51 @@ def on_voip_call_received_messagedialog_response(self, dialog, response):
session.reject_content(content)
dialog.destroy()
class CertificatDialog(InformationDialog):
def __init__(self, parent, account, cert):
issuer = cert.get_issuer()
subject = cert.get_subject()
InformationDialog.__init__(self,
_('Certificate for account %s') % account, _('''<b>Issued to:</b>
Common Name (CN): %(scn)s
Organization (O): %(sorg)s
Organizationl Unit (OU): %(sou)s
Serial Number: %(sn)s
<b>Issued by:</b>
Common Name (CN): %(icn)s
Organization (O): %(iorg)s
Organizationl Unit (OU): %(iou)s
<b>Validity:</b>
Issued on: %(io)s
Expires on: %(eo)s
<b>Fingerprint</b>
SHA1 Fingerprint: %(sha1)s''') % {
'scn': subject.commonName, 'sorg': subject.organizationName,
'sou': subject.organizationalUnitName,
'sn': cert.get_serial_number(), 'icn': issuer.commonName,
'iorg': issuer.organizationName,
'iou': issuer.organizationalUnitName,
'io': cert.get_notBefore(), 'eo': cert.get_notAfter(),
'sha1': cert.digest('sha1')})
self.set_transient_for(parent)
class CheckFingerprintDialog(YesNoDialog):
def __init__(self, pritext='', sectext='', checktext='',
on_response_yes=None, on_response_no=None, account=None, certificate=None):
self.account = account
self.cert = certificate
YesNoDialog.__init__(self, pritext, sectext, checktext, on_response_yes,
on_response_no)
b = gtk.Button('View cert...')
b.connect('clicked', self.on_cert_clicked)
b.show_all()
area = self.get_action_area()
area.pack_start(b)
def on_cert_clicked(self, button):
d = CertificatDialog(self, self.account, self.cert)
\ No newline at end of file
......@@ -1250,8 +1250,9 @@ def on_no():
self.instances[account]['online_dialog']['fingerprint_error'].\
destroy()
self.instances[account]['online_dialog']['fingerprint_error'] = \
dialogs.YesNoDialog(pritext, sectext, on_response_yes=on_yes,
on_response_no=on_no)
dialogs.CheckFingerprintDialog(pritext, sectext, on_response_yes=on_yes,
on_response_no=on_no, account=obj.conn.name,
certificate=obj.certificate)
def handle_event_plain_connection(self, obj):
# ('PLAIN_CONNECTION', account, (connection))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment