Edujugon / PushNotification

PHP and Laravel Package to send push notifications to Android and IOS devices.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to set private key

nicolascarelli opened this issue · comments

Hi Edu and congrats x your package;

I m getting this error "response": {
"success": false,
"error": "Connection problem: stream_socket_client(): Unable to set private key file `/var/www/html/ws/config/iosCertificates/aps_development.pem'\n"
}

The path to the to cert is ok.
The file has 644 permissions.

Thanks in advance.

Hi @nicolascarelli ,

How did you converting the key file to pem? I think that can be the cause of the issue..
Otherwise, make sure that your passPhrase is correct if required..

Hi @Edujugon

  1. I ve generate the .crt file according to IOS Certificates guide:
    "In the Certificate Information window, enter the following information:
    In the User Email Address field, enter your email address.
    In the Common Name field, create a name for your private key (e.g., John Doe Dev Key).
    The CA Email Address field should be left empty.
    In the "Request is" group, select the "Saved to disk" option.
    Click Continue within Keychain Access to complete the CSR generating process."

  2. I ve converted the .crt file into a .pem file like this:
    openssl x509 -in aps_development.crt -out aps_development.pem -outform PEM

Could you recheck that you're using a valid passphrase for that cert?
Also, could you show the config params for APN in config/pushnotification.php

I think there s no passphrase
'apn' => [
'certificate' => DIR . '/iosCertificates/aps_development.pem',
//'passPhrase' => '1234', //Optional
//'passFile' => DIR . '/iosCertificates/yourKey.pem', //Optional
'dry_run' => true
]

I would say the issue is in with the certificate file or with the passPhrase..
Could you try again creating the pem and use the passPhrase if required?

You could also check certificate validity and connectivity to APNS:
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert apns-dev-cert.pem -key apns-dev-key.pem

@Edujugon you were right;
Now it's working
Thanks and congrats

Cool! 🎉