[CalendarServer-changes] [10919] CalendarServer/trunk/twistedcaldav/stdconfig.py

source_changes at macosforge.org source_changes at macosforge.org
Wed Mar 13 19:53:42 PDT 2013


Revision: 10919
          http://trac.calendarserver.org//changeset/10919
Author:   sagen at apple.com
Date:     2013-03-13 19:53:41 -0700 (Wed, 13 Mar 2013)
Log Message:
-----------
Automatically disable APNS is certs are missing

Modified Paths:
--------------
    CalendarServer/trunk/twistedcaldav/stdconfig.py

Modified: CalendarServer/trunk/twistedcaldav/stdconfig.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/stdconfig.py	2013-03-14 01:29:15 UTC (rev 10918)
+++ CalendarServer/trunk/twistedcaldav/stdconfig.py	2013-03-14 02:53:41 UTC (rev 10919)
@@ -1366,10 +1366,20 @@
             ):
                 if not service[protocol]["Topic"]:
                     certPath = service[protocol]["CertificatePath"]
-                    if certPath and os.path.exists(certPath):
-                        topic = getAPNTopicFromCertificate(certPath)
-                        service[protocol]["Topic"] = topic
+                    if certPath:
+                        if os.path.exists(certPath):
+                            topic = getAPNTopicFromCertificate(certPath)
+                            service[protocol]["Topic"] = topic
+                        else:
+                            log.error("APNS certificate not found: %s" %
+                                (certPath,))
+                    else:
+                        log.error("APNS certificate path not specified")
 
+                if not service[protocol]["Topic"]:
+                    log.error("APNS cannot proceed; disabling APNS")
+                    service["Enabled"] = False
+
                 # If we already have the cert passphrase, don't fetch it again
                 if service[protocol]["Passphrase"]:
                     continue
@@ -1379,13 +1389,13 @@
                 try:
                     passphrase = getPasswordFromKeychain(accountName)
                     service[protocol]["Passphrase"] = passphrase
-                    log.info("%s APN certificate passphrase retreived from keychain" % (protocol,))
+                    log.info("%s APNS certificate passphrase retreived from keychain" % (protocol,))
                 except KeychainAccessError:
                     # The system doesn't support keychain
                     pass
                 except KeychainPasswordNotFound:
                     # The password doesn't exist in the keychain.
-                    log.info("%s APN certificate passphrase not found in keychain" % (protocol,))
+                    log.info("%s APNS certificate passphrase not found in keychain" % (protocol,))
 
 
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20130313/48a38586/attachment.html>


More information about the calendarserver-changes mailing list