[CalendarServer-changes] [3440] CalendarServer/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Tue Dec 2 14:02:42 PST 2008
Revision: 3440
http://trac.macosforge.org/projects/calendarserver/changeset/3440
Author: wsanchez at apple.com
Date: 2008-12-02 14:02:41 -0800 (Tue, 02 Dec 2008)
Log Message:
-----------
Start twext module for Twisted extensions. Move ChainingOpenSSLContextFactory from tap to there.
Modified Paths:
--------------
CalendarServer/trunk/calendarserver/tap/caldav.py
CalendarServer/trunk/test
CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py
Added Paths:
-----------
CalendarServer/trunk/twext/
CalendarServer/trunk/twext/__init__.py
CalendarServer/trunk/twext/internet/
CalendarServer/trunk/twext/internet/__init__.py
CalendarServer/trunk/twext/internet/ssl.py
Modified: CalendarServer/trunk/calendarserver/tap/caldav.py
===================================================================
--- CalendarServer/trunk/calendarserver/tap/caldav.py 2008-12-02 19:24:21 UTC (rev 3439)
+++ CalendarServer/trunk/calendarserver/tap/caldav.py 2008-12-02 22:02:41 UTC (rev 3440)
@@ -19,11 +19,10 @@
from subprocess import Popen, PIPE
from pwd import getpwnam
from grp import getgrnam
-from OpenSSL import SSL
+from OpenSSL.SSL import Error as SSLError
from zope.interface import implements
-from twisted.internet.ssl import DefaultOpenSSLContextFactory
from twisted.internet.address import IPv4Address
from twisted.python.log import FileLogObserver
from twisted.python.usage import Options, UsageError
@@ -37,6 +36,8 @@
from twisted.web2.auth.basic import BasicCredentialFactory
from twisted.web2.server import Site
+from twext.internet.ssl import ChainingOpenSSLContextFactory
+
from twistedcaldav.log import Logger, logLevelForNamespace, setLogLevelForNamespace
from twistedcaldav.accesslog import DirectoryLogWrapperResource
from twistedcaldav.accesslog import RotatingFileAccessLoggingObserver
@@ -335,38 +336,7 @@
return None
-class ChainingOpenSSLContextFactory (DefaultOpenSSLContextFactory):
- def __init__(
- self, privateKeyFileName, certificateFileName,
- sslmethod=SSL.SSLv23_METHOD, certificateChainFile=None,
- passwdCallback=None
- ):
- self.certificateChainFile = certificateChainFile
- self.passwdCallback = passwdCallback
- DefaultOpenSSLContextFactory.__init__(
- self,
- privateKeyFileName,
- certificateFileName,
- sslmethod=sslmethod
- )
-
- def cacheContext(self):
- # Unfortunate code duplication.
- ctx = SSL.Context(self.sslmethod)
-
- if self.passwdCallback is not None:
- ctx.set_passwd_cb(self.passwdCallback)
-
- ctx.use_certificate_file(self.certificateFileName)
- ctx.use_privatekey_file(self.privateKeyFileName)
-
- if self.certificateChainFile != "":
- ctx.use_certificate_chain_file(self.certificateChainFile)
-
- self._context = ctx
-
-
class CalDAVServiceMaker (object):
implements(IPlugin, IServiceMaker)
@@ -683,7 +653,7 @@
certificateChainFile=config.SSLAuthorityChain,
passwdCallback=getSSLPassphrase,
)
- except SSL.Error, e:
+ except SSLError, e:
log.error("Unable to set up SSL context factory: %s" % (e,))
log.error("Disabling SSL port: %s" % (port,))
else:
Modified: CalendarServer/trunk/test
===================================================================
--- CalendarServer/trunk/test 2008-12-02 19:24:21 UTC (rev 3439)
+++ CalendarServer/trunk/test 2008-12-02 22:02:41 UTC (rev 3440)
@@ -62,7 +62,7 @@
if [ $# -gt 0 ]; then
test_modules="$@";
else
- test_modules="calendarserver twistedcaldav twisted";
+ test_modules="calendarserver twistedcaldav twext twisted";
fi;
cd "${wd}" && "${twisted}/bin/trial" ${random} ${until_fail} ${no_colour} ${coverage} ${test_modules};
Added: CalendarServer/trunk/twext/__init__.py
===================================================================
--- CalendarServer/trunk/twext/__init__.py (rev 0)
+++ CalendarServer/trunk/twext/__init__.py 2008-12-02 22:02:41 UTC (rev 3440)
@@ -0,0 +1,19 @@
+##
+# Copyright (c) 2005-2007 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+"""
+Extentions to the Twisted Framework.
+"""
Added: CalendarServer/trunk/twext/internet/ssl.py
===================================================================
--- CalendarServer/trunk/twext/internet/ssl.py (rev 0)
+++ CalendarServer/trunk/twext/internet/ssl.py 2008-12-02 22:02:41 UTC (rev 3440)
@@ -0,0 +1,59 @@
+##
+# Copyright (c) 2005-2008 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+"""
+Extentions to twisted.internet.ssl.
+"""
+
+__all__ = [
+ "ChainingOpenSSLContextFactory",
+]
+
+from OpenSSL.SSL import Context as SSLContext, SSLv23_METHOD
+
+from twisted.internet.ssl import DefaultOpenSSLContextFactory
+
+
+class ChainingOpenSSLContextFactory (DefaultOpenSSLContextFactory):
+ def __init__(
+ self, privateKeyFileName, certificateFileName,
+ sslmethod=SSLv23_METHOD, certificateChainFile=None,
+ passwdCallback=None
+ ):
+ self.certificateChainFile = certificateChainFile
+ self.passwdCallback = passwdCallback
+
+ DefaultOpenSSLContextFactory.__init__(
+ self,
+ privateKeyFileName,
+ certificateFileName,
+ sslmethod=sslmethod
+ )
+
+ def cacheContext(self):
+ # Unfortunate code duplication.
+ ctx = SSLContext(self.sslmethod)
+
+ if self.passwdCallback is not None:
+ ctx.set_passwd_cb(self.passwdCallback)
+
+ ctx.use_certificate_file(self.certificateFileName)
+ ctx.use_privatekey_file(self.privateKeyFileName)
+
+ if self.certificateChainFile != "":
+ ctx.use_certificate_chain_file(self.certificateChainFile)
+
+ self._context = ctx
Modified: CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py 2008-12-02 19:24:21 UTC (rev 3439)
+++ CalendarServer/trunk/twistedcaldav/scheduling/ischedule.py 2008-12-02 22:02:41 UTC (rev 3440)
@@ -28,6 +28,8 @@
from twisted.web2.http_headers import Headers
from twisted.web2.http_headers import MimeType
+from twext.internet.ssl import ChainingOpenSSLContextFactory
+
from twistedcaldav import caldavxml
from twistedcaldav.caldavxml import caldav_namespace
from twistedcaldav.config import config
@@ -123,7 +125,6 @@
try:
from twisted.internet import reactor
if self.server.ssl:
- from calendarserver.tap.caldav import ChainingOpenSSLContextFactory
context = ChainingOpenSSLContextFactory(config.SSLPrivateKey, config.SSLCertificate, certificateChainFile=config.SSLAuthorityChain)
proto = (yield ClientCreator(reactor, HTTPClientProtocol).connectSSL(self.server.host, self.server.port, context))
else:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20081202/8de0ae1d/attachment-0001.html>
More information about the calendarserver-changes
mailing list