def _apns_create_socket(address_tuple):
	certfile = SETTINGS.get("APNS_CERTIFICATE")
	if not certfile:
		raise ImproperlyConfigured(
			'You need to set PUSH_NOTIFICATIONS_SETTINGS["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))

	ca_certs = SETTINGS.get("APNS_CA_CERTIFICATES")

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

	return sock
dataset/ETHPy150Open jleclanche/django-push-notifications/push_notifications/apns.py/_apns_create_socket/original