This commit is contained in:
JJTech0130 2023-04-05 21:04:41 -04:00
parent 3a946a152e
commit 10ddee20df
No known key found for this signature in database
GPG key ID: 23C92EBCCF8F93D6
2 changed files with 8 additions and 5 deletions

View file

@ -17,10 +17,10 @@ def connect(private_key=None, cert=None):
# Wrap the socket in TLS
sock = tlslite.TLSConnection(sock)
# Parse the certificate and private key
cert = tlslite.X509CertChain([tlslite.X509().parse(cert)])
private_key = tlslite.parsePEMKey(private_key, private=True)
cert_parsed = tlslite.X509CertChain([tlslite.X509().parse(cert)])
private_key_parsed = tlslite.parsePEMKey(private_key, private=True)
# Handshake with the server
sock.handshakeClientCert(cert, private_key, alpn=ALPN)
sock.handshakeClientCert(cert_parsed, private_key_parsed, alpn=ALPN)
return sock, private_key, cert

View file

@ -1,5 +1,8 @@
import apns
from base64 import b64decode, b64encode
c = apns.APNSConnection()
print(f"Push Token: {b64encode(c.token).decode()}")
conn1 = apns.APNSConnection()
print(f"Push Token 1: {b64encode(conn1.token).decode()}")
conn2 = apns.APNSConnection(cert=conn1.cert, private_key=conn1.private_key, token=conn1.token)
print(f"Push Token 2: {b64encode(conn2.token).decode()}")