Add certfp support. Closes GH-468.

This commit is contained in:
Valentin Lorentz 2013-11-10 11:45:01 +01:00
parent 2b12a33d82
commit e65a722b2f
2 changed files with 7 additions and 1 deletions

View File

@ -306,6 +306,9 @@ def registerNetwork(name, password='', ssl=False, sasl_username='',
registerGlobalValue(network, 'ssl', registry.Boolean(ssl, registerGlobalValue(network, 'ssl', registry.Boolean(ssl,
_("""Determines whether the bot will attempt to connect with SSL _("""Determines whether the bot will attempt to connect with SSL
sockets to %s.""") % name)) sockets to %s.""") % name))
registerGlobalValue(network, 'certfile', registry.String('',
_("""Determines what certificate file (if any) the bot will use to
connect with SSL sockets to %s.""") % name))
registerChannelValue(network.channels, 'key', registry.String('', registerChannelValue(network.channels, 'key', registry.String('',
_("""Determines what key (if any) will be used to join the _("""Determines what key (if any) will be used to join the
channel."""), private=True)) channel."""), private=True))

View File

@ -304,7 +304,10 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
try: try:
if getattr(conf.supybot.networks, self.irc.network).ssl(): if getattr(conf.supybot.networks, self.irc.network).ssl():
assert globals().has_key('ssl') assert globals().has_key('ssl')
self.conn = ssl.wrap_socket(self.conn) certfile = getattr(conf.supybot.networks, self.irc.network) \
.certfile()
self.conn = ssl.wrap_socket(self.conn,
certfile=certfile or None)
self.conn.connect((address, server[1])) self.conn.connect((address, server[1]))
def setTimeout(): def setTimeout():
self.conn.settimeout(conf.supybot.drivers.poll()) self.conn.settimeout(conf.supybot.drivers.poll())