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
1 changed files with 5 additions and 2 deletions

View File

@ -306,8 +306,11 @@ class SocketDriver(drivers.IrcDriver, drivers.ServersMixin):
assert globals().has_key('ssl')
certfile = getattr(conf.supybot.networks, self.irc.network) \
.certfile()
self.conn = ssl.wrap_socket(self.conn,
certfile=certfile or None)
if not certfile or not os.path.isfile(certfile):
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]))
def setTimeout():
self.conn.settimeout(conf.supybot.drivers.poll())