Commit b5328fca authored by nextime's avatar nextime

Disable SSLv3 for mail client

parent 4197d276
...@@ -23,8 +23,7 @@ ...@@ -23,8 +23,7 @@
import sys import sys
from OpenSSL.SSL import SSLv3_METHOD from OpenSSL.SSL import OP_NO_SSLv3
from twisted.mail.smtp import ESMTPSenderFactory from twisted.mail.smtp import ESMTPSenderFactory
from twisted.python.usage import Options, UsageError from twisted.python.usage import Options, UsageError
from twisted.internet.ssl import ClientContextFactory from twisted.internet.ssl import ClientContextFactory
...@@ -38,6 +37,18 @@ import logging ...@@ -38,6 +37,18 @@ import logging
log = logging.getLogger( 'Mail' ) log = logging.getLogger( 'Mail' )
class ContextFactory(ClientContextFactory):
"""Context factory that disables SSLv3 (POODLE attack)."""
def getContext(self):
"""Get the parent context but disable SSLv3."""
ctx = ClientContextFactory.getContext(self)
ctx.set_options(OP_NO_SSLv3)
return ctx
class DMEmail(object): class DMEmail(object):
needauth=False needauth=False
...@@ -107,8 +118,8 @@ class DMEmail(object): ...@@ -107,8 +118,8 @@ class DMEmail(object):
def send(self, usemime=True): def send(self, usemime=True):
log.info("Sending email from "+str(self.sender)+" to "+str(self.to)+" with subject "+str(self.subject)) log.info("Sending email from "+str(self.sender)+" to "+str(self.to)+" with subject "+str(self.subject))
contextFactory = ClientContextFactory() contextFactory = ContextFactory()
contextFactory.method = SSLv3_METHOD #contextFactory.method = SSLv3_METHOD
if usemime: if usemime:
msg = MIMEText(self.message) msg = MIMEText(self.message)
......
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