alloy / lowdown

A Ruby client for the HTTP/2 version of the Apple Push Notification Service.
MIT License
120 stars 15 forks source link

TopicDisAllow #23

Closed rayway30419 closed 8 years ago

rayway30419 commented 8 years ago

Hi alloy,

After I user the certificate to establish a lowdown client,

the client's default_topic shows "!xxxxxx". ( '!' + bundle id )

Then when I send push notifications to devices, apns response me 400 with reason "TopicDisallowed".

It happens to 5/32 apps.

Do you have any idea?

alloy commented 8 years ago

That probably means that the topics field of the certificate may contain other values than I expected.

Care to make a PR for the format that your certificate holds?

rayway30419 commented 8 years ago

May I send my certificate by email?

rayway30419 commented 8 years ago

I find the others certifications topic is "$ + bundle_id"

alloy commented 8 years ago

You don’t need to send me your certificate, you can check the value yourself like so:

$ irb -r openssl
irb(main):001:0> cert = OpenSSL::X509::Certificate.new(File.read('/path/to/certificate.pem')); nil
=> nil
irb(main):002:0> cert.extensions.find { |ext| ext.oid == '1.2.840.113635.100.6.3.6' }.value
=> "0d..net.artsy.artsy0...app..net.artsy.artsy.voip0...voip..net.artsy.artsy.complication0...complication"
rayway30419 commented 8 years ago

I got

"0...!com.kdanmobile.ipad.pdfreaderlite0...app.&com.kdanmobile.ipad.pdfreaderlite.voip0...voip..com.kdanmobile.ipad.pdfreaderlite.complication0...complication"

and lowdown default_topic

@default_topic="!com.kdanmobile.ipad.pdfreaderlite"

alloy commented 8 years ago

Interesting, well it’s definitely clear where those ! and & characters are coming in from. I’m still not sure what they signify and feel like I might be overlooking a proper parser for the format of this value 🤔

But for now it should be easy enough for you to make a PR that adds entries formatted like yours to the tests and then make the parsing work for both cases.

rayway30419 commented 8 years ago

I thought it is not easy to me, but I will give it a try. :(

rayway30419 commented 8 years ago

Hi @alloy,

I find this situation occurs in other certificates, too.

If this parser is only want to grep the bundle id, why not just parse the subject? :(

I've tried to reproduce certifications and using other language to parse it but get the same result.

alloy commented 8 years ago

@rayway30419 The reason that it’s not just the bundle ID is that a universal certificate may be used for more than 1 purpose. I pushed a fix that should be the right fix, let me know if it works for you.

rayway30419 commented 8 years ago

Hi @alloy The fix by ASN1 looks well. I thought you can commit this modification into rubygems. :) thx

sposin commented 8 years ago

Has this fix been released? We are experiencing this error (only in one of our apps).

mikekavouras commented 8 years ago

@alloy can confirm that this is fixed on master, but it doesn't look like it's been released. Fetching from rubygems.org still has the bug.

alloy commented 8 years ago

Hey, just got back from holiday.

My bad, I’ll put out a release this week. Thanks for reminding me.