Connect to prod APN with development certificate

I use this Ruby code to get APN errors on failed clicks:

if IO.select([ssl], nil, nil, 5) read_buffer = ssl.read(6) process_error_response(read_buffer) end 

I noticed a strange situation where IO.select is not zero, but read_buffer returns an empty string. After some debugging, I realized that this happens if you connect to gateway.push.apple.com with a development APN certificate, and the same thing happens if you connect to gateway.sandbox.push.apple.com with a production certificate.

Is there a way to programmatically determine what it is, for example. if you received a push certificate from the user and said that it’s production / development, but can’t check this fact on the Apple developer’s website? I would have thought that the connection would be rejected, but instead it would be created, but in a partially broken state.

+6
source share
2 answers

Well, this is not a way to check if the APNS certificate is valid, but you can check it if you want to determine if it is a development or production. There will be a line “Developer” in development, while in production there will be a line “Production”.

0
source

One way is to open the certificate and check the topic, for example:

 require 'openssl' def production?(cert_path) certificate = ::OpenSSL::X509::Certificate.new(File.read(cert_path)) !certificate.subject.to_s.include?('Development') end 

For production certificates, the subject is as follows:

 "Apple Production IOS Push Services: com.mybundle.app..." 

For development certificates, it looks like this:

 "Apple Development IOS Push Services: com.mybundle.app..." 
0
source

Source: https://habr.com/ru/post/914746/


All Articles