Skip to content

Commit

Permalink
Implement an APNS_CA_CERTIFICATES setting
Browse files Browse the repository at this point in the history
  • Loading branch information
dpretty authored and jleclanche committed Jun 30, 2015
1 parent d992d39 commit 886b386
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ In order to use GCM, you are required to include ``GCM_API_KEY``.
For APNS, you are required to include ``APNS_CERTIFICATE``.

- ``APNS_CERTIFICATE``: Absolute path to your APNS certificate file. Certificates with passphrases are not supported.
- ``APNS_CA_CERTIFICATES``: Absolute path to a CA certificates file for APNS. Optional - do not set if not needed. Defaults to None.
- ``GCM_API_KEY``: Your API key for GCM.
- ``APNS_HOST``: The hostname used for the APNS sockets.
- When ``DEBUG=True``, this defaults to ``gateway.sandbox.push.apple.com``.
Expand Down
4 changes: 3 additions & 1 deletion push_notifications/apns.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ def _apns_create_socket(address_tuple):
except Exception as e:
raise ImproperlyConfigured("The APNS certificate file at %r is not readable: %s" % (certfile, e))

ca_certs = SETTINGS.get("APNS_CA_CERTIFICATES")

sock = socket.socket()
sock = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_TLSv1, certfile=certfile)
sock = ssl.wrap_socket(sock, ssl_version=ssl.PROTOCOL_TLSv1, certfile=certfile, ca_certs=ca_certs)
sock.connect(address_tuple)

return sock
Expand Down

0 comments on commit 886b386

Please sign in to comment.