Closed asifshiraz closed 10 months ago
What is the datatype of your private_key variable? Is it bytes
as specified in the typing, and not a string?
I'm just doing
key_file = open("./SubscriptionKey_S84FG2P8CL.p8", "r")
private_key = key_file.read()
Okay.. setting it to rb like
key_file
= open("./SubscriptionKey_S84FG2P8CL.p8", "rb")`
works. Is this the right approach?
Yes, this is the expected approach
When running the first example, I get the following error:
Traceback (most recent call last): File "C:\code\qoria\appstore-client\main.py", line 14, in
client = AppStoreServerAPIClient(private_key, key_id, issuer_id, bundle_id, environment)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code\qoria\appstore-client\venv\Lib\site-packages\appstoreserverlibrary\api_client.py", line 97, in init
self._signing_key = serialization.load_pem_private_key(signing_key, password=None, backend=default_backend())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code\qoria\appstore-client\venv\Lib\site-packages\cryptography\hazmat\primitives\serialization\base.py", line 25, in load_pem_private_key
return ossl.load_pem_private_key(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code\qoria\appstore-client\venv\Lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 747, in load_pem_private_key
return self._load_key(
^^^^^^^^^^^^^^^
File "C:\code\qoria\appstore-client\venv\Lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 897, in _load_key
mem_bio = self._bytes_to_bio(data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\code\qoria\appstore-client\venv\Lib\site-packages\cryptography\hazmat\backends\openssl\backend.py", line 479, in _bytes_to_bio
data_ptr = self._ffi.from_buffer(data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: from_buffer() cannot return the address of a unicode object