Socket: Check if certertificate file exists before using it.

This commit is contained in:
Valentin Lorentz 2013-11-27 07:24:49 +00:00
parent 13d2746454
commit 4c24f30504

View File

@ -306,8 +306,11 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
assert globals().has_key('ssl') assert globals().has_key('ssl')
certfile = getattr(conf.supybot.networks, self.irc.network) \ certfile = getattr(conf.supybot.networks, self.irc.network) \
.certfile() .certfile()
self.conn = ssl.wrap_socket(self.conn, if not certfile or not os.path.isfile(certfile):
certfile=certfile or None) drivers.log.warning('Could not find cert file %s.' %
certfile)
certfile = None
self.conn = ssl.wrap_socket(self.conn, certfile=certfile)
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())