stephenmuss / django-ios-notifications

Django iOS Notifications makes it easy to send push notifications to iOS devices
Other
230 stars 72 forks source link

Unable to add APNS service with passphrase #65

Closed gorros closed 8 years ago

gorros commented 9 years ago

Hi,

I am trying to add APNS service with passphrase, but unfortunatly it results in following error

Exception Type: TypeError
Exception Value:    Last argument must be string or callable
Exception Location: /var/www/venv/lib/python3.4/site-packages/OpenSSL/crypto.py in callback, line 1935

I assume that something is wrong with this method:

def callback(self):
        if self._passphrase is None:
            return _ffi.NULL
        elif isinstance(self._passphrase, bytes):
            return _ffi.NULL
        elif callable(self._passphrase):
            return _ffi.callback("pem_password_cb", self._read_passphrase)
        else:
            raise TypeError("Last argument must be string or callable")

Because even if passphrase is string it wil raise TypeError

Looking forward for reply, Thanks.

UrK commented 9 years ago

@gorros, if you were able to solve the issue yourself, I would be really glad to know what the solution is.

robosung commented 9 years ago

@gorros @UrK I'm getting a similar issue. Would be great to hear how you resolved it. Thanks

UrK commented 9 years ago

@robosung I have not resolved it. I stopped using the library. ;)

gorros commented 9 years ago

@robosung

As I remember now, we switched to https://github.com/jleclanche/django-push-notifications, but again it does not support certificates with passphrases. Nevertheless we decided stick to later one and do not use certificates with passphrases. But unfortunately I don't remember what was the final argument.

robosung commented 9 years ago

@UrK @gorros thank you for the update.

iiilx commented 8 years ago

@gorros cast the passphrase to str (might be unicode). that fixed it for me.

stephenmuss commented 8 years ago

See comment directly above.

tludwiczak commented 7 years ago

.encode() solve problem for me.

e.g. rsa_private_key = load_privatekey( OpenSSL.crypto.FILETYPE_PEM, private_key, secret.encode())

when secret is string