nomad-cli / houston

Apple Push Notifications; No Dirigible Required
http://nomad-cli.com
MIT License
2.93k stars 229 forks source link

Exception sending notification: password must be at least 4 bytes #146

Closed avsmirnov567 closed 7 years ago

avsmirnov567 commented 7 years ago

Faced exception "Exception sending notification: password must be at least 4 bytes", when I tried to send voip push from my home mac. Used command:

apn push "my_credentials_string_here" -c VOIP.pem -m "sent"

From office machine, with exactly the same command I usually get "1 push notification sent successfully". I guess, that I have to somehow setup my home machine, but I still can't get it.

dankimio commented 7 years ago

Did you specify your passphrase? Use -p if you want to specify one.

avsmirnov567 commented 7 years ago

@dankimio, thank you for the answer, yes, it helped me, after I set longer passphrase. But I get "2 push notifications sent successfully" instead of 1 now. By the way, why it is demanded to specify passphrase in this case? I suggest it is because my сertificate was signed and exported on my office machine, am I right?

dankimio commented 7 years ago

@avsmirnov567 How did you generate your pem certificate? If you entered a passphrase when creating the certificate then you should specify it when sending notifications.

avsmirnov567 commented 7 years ago

@dankimio, thank you, now I have got it clearly.

mpvosseller commented 6 years ago

Seems to me that there is in fact a bug here. If I generate a .pem with an unencrypted private key (no password) apn push still requires a password to be provided. To get around this you can simply provide any value that is 4 or more bytes long as the password (e.g. 1234) and it will successfully send the notification. Ideally the tool should not require a password in this case.

Steps to reproduce: • Convert .p12 to .pem as described here using an "Unencrypted private key". (So run openssl pkcs12 with the -nodes option). • Run apn push "<token>" -c apple_push_notification.pem -m "Hello from the command line" and observe an error like "Exception sending notification: password must be at least 4 bytes" (this should have worked because there is no passphrase) • Run apn push "<token>" -c apple_push_notification.pem -m "Hello from the command line" -p and specify any garbage (e.g. 1234) as the password and observe that it successfully sends the notification.

mpvosseller commented 6 years ago

I created a pull request here to fix this issue: https://github.com/nomad/houston/pull/158