def _apns_create_socket(address_tuple, app_id):
app_settings = get_app_settings(app_id)
if not app_settings:
raise ImproperlyConfigured('You need to set UNIVERSAL_NOTIFICATIONS_MOBILE_APPS[app_id]'
' to send messages through APNS')
certfile = app_settings.get("APNS_CERTIFICATE")
if not certfile:
raise ImproperlyConfigured(
'You need to set UNIVERSAL_NOTIFICATIONS_MOBILE_APPS[app_id]["APNS_CERTIFICATE"] '
'to send messages through APNS.'
)
try:
with open(certfile, "r") as f:
f.read()
except Exception as e:
raise ImproperlyConfigured("The APNS certificate file at %r is not readable: %s" % (certfile, e))
sock = socket.socket()
sock = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_TLSv1, certfile=certfile)
sock.connect(address_tuple)
return sock
评论列表
文章目录