BadDeviceToken from APNs gateway

2,780 views
Skip to first unread message

Carstein Seeberg

unread,
May 26, 2017, 6:05:44 AM5/26/17
to pushy
I'm looking for a solution to push notifications to my app from my application server, and I would really like to implement my solution with pushy.
However, I ran into an issue while testing.

Why am I getting the BadDeviceToken response from APNs ?  
I have attempted both authentication methods, TLS and Token with the same response.
So, it would seem that there really is a bad device token :-)

But...

I'm able to send push notifications using http://www.pushwatch.com with the same TLS certificate (however as .pem) to the same device token that I specify using pushy.
I have also verified the "topic" in the certificate file.

Any clues ?

Best regards,
Carstein


Enclosing the trace-output from a TLS run:
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
2017-05-26 11:55:42 DEBUG TestPushy:31 - Starting....
2017-05-26 11:55:42 DEBUG InternalLoggerFactory:71 - Using SLF4J as the default logging framework
2017-05-26 11:55:42 DEBUG NativeLibraryLoader:71 - -Dio.netty.tmpdir: C:\Users\carst\AppData\Local\Temp (java.io.tmpdir)
2017-05-26 11:55:42 DEBUG NativeLibraryLoader:71 - -Dio.netty.native.workdir: C:\Users\carst\AppData\Local\Temp (io.netty.tmpdir)
2017-05-26 11:55:42 DEBUG NativeLibraryLoader:76 - Successfully loaded the library: netty-tcnative-windows-x86_64
2017-05-26 11:55:42 DEBUG OpenSsl:76 - netty-tcnative using native library: BoringSSL
2017-05-26 11:55:42 DEBUG PlatformDependent0:76 - -Dio.netty.noUnsafe: false
2017-05-26 11:55:42 DEBUG PlatformDependent0:71 - sun.misc.Unsafe.theUnsafe: available
2017-05-26 11:55:42 DEBUG PlatformDependent0:71 - sun.misc.Unsafe.copyMemory: available
2017-05-26 11:55:42 DEBUG PlatformDependent0:71 - java.nio.Buffer.address: available
2017-05-26 11:55:42 DEBUG PlatformDependent0:71 - direct buffer constructor: available
2017-05-26 11:55:42 DEBUG PlatformDependent0:76 - java.nio.Bits.unaligned: available, true
2017-05-26 11:55:42 DEBUG PlatformDependent0:91 - jdk.internal.misc.Unsafe.allocateUninitializedArray(int): unavailable
java.lang.ClassNotFoundException: jdk.internal.misc.Unsafe
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at io.netty.util.internal.PlatformDependent0$6.run(PlatformDependent0.java:295)
at java.security.AccessController.doPrivileged(Native Method)
at io.netty.util.internal.PlatformDependent0.<clinit>(PlatformDependent0.java:288)
at io.netty.util.internal.PlatformDependent.getSystemClassLoader(PlatformDependent.java:895)
at io.netty.util.internal.PlatformDependent.isAndroid0(PlatformDependent.java:919)
at io.netty.util.internal.PlatformDependent.<clinit>(PlatformDependent.java:70)
at io.netty.handler.ssl.util.ThreadLocalInsecureRandom.random(ThreadLocalInsecureRandom.java:99)
at io.netty.handler.ssl.util.ThreadLocalInsecureRandom.nextBytes(ThreadLocalInsecureRandom.java:53)
at java.math.BigInteger.randomBits(Unknown Source)
at java.math.BigInteger.<init>(Unknown Source)
at java.math.BigInteger.largePrime(Unknown Source)
at java.math.BigInteger.probablePrime(Unknown Source)
at sun.security.rsa.RSAKeyPairGenerator.generateKeyPair(Unknown Source)
at java.security.KeyPairGenerator$Delegate.generateKeyPair(Unknown Source)
at io.netty.handler.ssl.util.SelfSignedCertificate.<init>(SelfSignedCertificate.java:140)
at io.netty.handler.ssl.util.SelfSignedCertificate.<init>(SelfSignedCertificate.java:110)
at io.netty.handler.ssl.util.SelfSignedCertificate.<init>(SelfSignedCertificate.java:88)
at io.netty.handler.ssl.util.SelfSignedCertificate.<init>(SelfSignedCertificate.java:79)
at io.netty.handler.ssl.OpenSsl.<clinit>(OpenSsl.java:144)
at com.turo.pushy.apns.SslUtil.getSslProvider(SslUtil.java:49)
at com.turo.pushy.apns.ApnsClientBuilder.build(ApnsClientBuilder.java:394)
at com.carstein.test.pushy.TestPushy.main(TestPushy.java:41)
2017-05-26 11:55:42 DEBUG PlatformDependent0:76 - java.nio.DirectByteBuffer.<init>(long, int): available
2017-05-26 11:55:42 DEBUG PlatformDependent:71 - Platform: Windows
2017-05-26 11:55:42 DEBUG PlatformDependent:76 - Java version: 8
2017-05-26 11:55:42 DEBUG PlatformDependent:76 - sun.misc.Unsafe: available
2017-05-26 11:55:42 DEBUG PlatformDependent:76 - -Dio.netty.tmpdir: C:\Users\carst\AppData\Local\Temp (java.io.tmpdir)
2017-05-26 11:55:42 DEBUG PlatformDependent:76 - -Dio.netty.bitMode: 64 (sun.arch.data.model)
2017-05-26 11:55:42 DEBUG PlatformDependent:76 - -Dio.netty.noPreferDirect: false
2017-05-26 11:55:42 DEBUG PlatformDependent:76 - -Dio.netty.maxDirectMemory: 2863661056 bytes
2017-05-26 11:55:42 DEBUG PlatformDependent:76 - -Dio.netty.uninitializedArrayAllocationThreshold: -1
2017-05-26 11:55:42 DEBUG CleanerJava6:71 - java.nio.ByteBuffer.cleaner(): available
2017-05-26 11:55:42 DEBUG AbstractByteBuf:81 - -Dio.netty.buffer.bytebuf.checkAccessible: true
2017-05-26 11:55:42 DEBUG ResourceLeakDetector:81 - -Dio.netty.leakDetection.level: simple
2017-05-26 11:55:42 DEBUG ResourceLeakDetector:81 - -Dio.netty.leakDetection.maxRecords: 4
2017-05-26 11:55:42 DEBUG ResourceLeakDetectorFactory:76 - Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector@6d7b4f4c
2017-05-26 11:55:42 DEBUG PooledByteBufAllocator:76 - -Dio.netty.allocator.numHeapArenas: 16
2017-05-26 11:55:42 DEBUG PooledByteBufAllocator:76 - -Dio.netty.allocator.numDirectArenas: 16
2017-05-26 11:55:42 DEBUG PooledByteBufAllocator:76 - -Dio.netty.allocator.pageSize: 8192
2017-05-26 11:55:42 DEBUG PooledByteBufAllocator:76 - -Dio.netty.allocator.maxOrder: 11
2017-05-26 11:55:42 DEBUG PooledByteBufAllocator:76 - -Dio.netty.allocator.chunkSize: 16777216
2017-05-26 11:55:42 DEBUG PooledByteBufAllocator:76 - -Dio.netty.allocator.tinyCacheSize: 512
2017-05-26 11:55:42 DEBUG PooledByteBufAllocator:76 - -Dio.netty.allocator.smallCacheSize: 256
2017-05-26 11:55:42 DEBUG PooledByteBufAllocator:76 - -Dio.netty.allocator.normalCacheSize: 64
2017-05-26 11:55:42 DEBUG PooledByteBufAllocator:76 - -Dio.netty.allocator.maxCachedBufferCapacity: 32768
2017-05-26 11:55:42 DEBUG PooledByteBufAllocator:76 - -Dio.netty.allocator.cacheTrimInterval: 8192
2017-05-26 11:55:42 DEBUG PooledByteBufAllocator:76 - -Dio.netty.allocator.useCacheForAllThreads: true
2017-05-26 11:55:42 DEBUG ByteBufUtil:76 - -Dio.netty.allocator.type: pooled
2017-05-26 11:55:42 DEBUG ByteBufUtil:76 - -Dio.netty.threadLocalDirectBufferSize: 65536
2017-05-26 11:55:42 DEBUG ByteBufUtil:76 - -Dio.netty.maxThreadLocalCharBufferSize: 16384
2017-05-26 11:55:42 DEBUG ResourceLeakDetectorFactory:76 - Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector@396f6598
2017-05-26 11:55:42 DEBUG ReferenceCountedOpenSslContext:71 - Default cipher suite (OpenSSL): [ECDHE-ECDSA-AES256-GCM-SHA384, ECDHE-ECDSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-GCM-SHA256, ECDHE-RSA-AES128-SHA, ECDHE-RSA-AES256-SHA, AES128-GCM-SHA256, AES128-SHA, AES256-SHA]
2017-05-26 11:55:42 DEBUG Recycler:76 - -Dio.netty.recycler.maxCapacityPerThread: 32768
2017-05-26 11:55:42 DEBUG Recycler:76 - -Dio.netty.recycler.maxSharedCapacityFactor: 2
2017-05-26 11:55:42 DEBUG Recycler:76 - -Dio.netty.recycler.linkCapacity: 16
2017-05-26 11:55:42 DEBUG Recycler:76 - -Dio.netty.recycler.ratio: 8
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 => ECDHE-ECDSA-CHACHA20-POLY1305
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 => ECDHE-ECDSA-CHACHA20-POLY1305
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305 => ECDHE-RSA-CHACHA20-POLY1305
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_RSA_WITH_CHACHA20_POLY1305 => ECDHE-RSA-CHACHA20-POLY1305
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_RSA_WITH_ECDHE_PSK_CHACHA20_POLY1305 => ECDHE-PSK-CHACHA20-POLY1305
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_RSA_WITH_ECDHE_PSK_CHACHA20_POLY1305 => ECDHE-PSK-CHACHA20-POLY1305
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 => ECDHE-ECDSA-AES128-GCM-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 => ECDHE-ECDSA-AES128-GCM-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 => ECDHE-RSA-AES128-GCM-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_RSA_WITH_AES_128_GCM_SHA256 => ECDHE-RSA-AES128-GCM-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_DHE_RSA_WITH_AES_128_GCM_SHA256 => DHE-RSA-AES128-GCM-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_DHE_RSA_WITH_AES_128_GCM_SHA256 => DHE-RSA-AES128-GCM-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 => ECDHE-ECDSA-AES256-GCM-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 => ECDHE-ECDSA-AES256-GCM-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 => ECDHE-RSA-AES256-GCM-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_RSA_WITH_AES_256_GCM_SHA384 => ECDHE-RSA-AES256-GCM-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_DHE_RSA_WITH_AES_256_GCM_SHA384 => DHE-RSA-AES256-GCM-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_DHE_RSA_WITH_AES_256_GCM_SHA384 => DHE-RSA-AES256-GCM-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA => ECDHE-ECDSA-AES128-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA => ECDHE-ECDSA-AES128-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 => ECDHE-ECDSA-AES128-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256 => ECDHE-ECDSA-AES128-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA => ECDHE-RSA-AES128-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_RSA_WITH_AES_128_CBC_SHA => ECDHE-RSA-AES128-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 => ECDHE-RSA-AES128-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_RSA_WITH_AES_128_CBC_SHA256 => ECDHE-RSA-AES128-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_RSA_WITH_ECDHE_PSK_AES128_CBC_SHA => ECDHE-PSK-AES128-CBC-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_RSA_WITH_ECDHE_PSK_AES128_CBC_SHA => ECDHE-PSK-AES128-CBC-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_DHE_RSA_WITH_AES_128_CBC_SHA => DHE-RSA-AES128-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_DHE_RSA_WITH_AES_128_CBC_SHA => DHE-RSA-AES128-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_DHE_RSA_WITH_AES_128_CBC_SHA256 => DHE-RSA-AES128-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_DHE_RSA_WITH_AES_128_CBC_SHA256 => DHE-RSA-AES128-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA => ECDHE-ECDSA-AES256-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA => ECDHE-ECDSA-AES256-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 => ECDHE-ECDSA-AES256-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_ECDSA_WITH_AES_256_CBC_SHA384 => ECDHE-ECDSA-AES256-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA => ECDHE-RSA-AES256-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_RSA_WITH_AES_256_CBC_SHA => ECDHE-RSA-AES256-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 => ECDHE-RSA-AES256-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_ECDHE_RSA_WITH_AES_256_CBC_SHA384 => ECDHE-RSA-AES256-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_RSA_WITH_ECDHE_PSK_AES256_CBC_SHA => ECDHE-PSK-AES256-CBC-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_RSA_WITH_ECDHE_PSK_AES256_CBC_SHA => ECDHE-PSK-AES256-CBC-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_DHE_RSA_WITH_AES_256_CBC_SHA => DHE-RSA-AES256-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_DHE_RSA_WITH_AES_256_CBC_SHA => DHE-RSA-AES256-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_DHE_RSA_WITH_AES_256_CBC_SHA256 => DHE-RSA-AES256-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_DHE_RSA_WITH_AES_256_CBC_SHA256 => DHE-RSA-AES256-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_RSA_WITH_AES_128_GCM_SHA256 => AES128-GCM-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_RSA_WITH_AES_128_GCM_SHA256 => AES128-GCM-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_RSA_WITH_AES_256_GCM_SHA384 => AES256-GCM-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_RSA_WITH_AES_256_GCM_SHA384 => AES256-GCM-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_RSA_WITH_AES_128_CBC_SHA => AES128-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_RSA_WITH_AES_128_CBC_SHA => AES128-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_RSA_WITH_AES_128_CBC_SHA256 => AES128-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_RSA_WITH_AES_128_CBC_SHA256 => AES128-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_PSK_WITH_AES_128_CBC_SHA => PSK-AES128-CBC-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_PSK_WITH_AES_128_CBC_SHA => PSK-AES128-CBC-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_RSA_WITH_AES_256_CBC_SHA => AES256-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_RSA_WITH_AES_256_CBC_SHA => AES256-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_RSA_WITH_AES_256_CBC_SHA256 => AES256-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_RSA_WITH_AES_256_CBC_SHA256 => AES256-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_PSK_WITH_AES_256_CBC_SHA => PSK-AES256-CBC-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_PSK_WITH_AES_256_CBC_SHA => PSK-AES256-CBC-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_RSA_WITH_3DES_EDE_CBC_SHA => DES-CBC3-SHA
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_RSA_WITH_3DES_EDE_CBC_SHA => DES-CBC3-SHA
2017-05-26 11:55:42 INFO  SslUtil:51 - Native SSL provider is available and supports ALPN; will use native provider.
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_DHE_DSS_WITH_AES_128_GCM_SHA256 => DHE-DSS-AES128-GCM-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_DHE_DSS_WITH_AES_128_GCM_SHA256 => DHE-DSS-AES128-GCM-SHA256
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: TLS_DHE_DSS_WITH_AES_256_GCM_SHA384 => DHE-DSS-AES256-GCM-SHA384
2017-05-26 11:55:42 DEBUG CipherSuiteConverter:81 - Cipher suite mapping: SSL_DHE_DSS_WITH_AES_256_GCM_SHA384 => DHE-DSS-AES256-GCM-SHA384
2017-05-26 11:55:42 DEBUG MultithreadEventLoopGroup:76 - -Dio.netty.eventLoopThreads: 16
2017-05-26 11:55:42 DEBUG NioEventLoop:76 - -Dio.netty.noKeySetOptimization: false
2017-05-26 11:55:42 DEBUG NioEventLoop:76 - -Dio.netty.selectorAutoRebuildThreshold: 512
2017-05-26 11:55:42 DEBUG PlatformDependent:71 - org.jctools-core.MpscChunkedArrayQueue: available
2017-05-26 11:55:42 TRACE NioEventLoop:46 - instrumented a special java.util.Set into: sun.nio.ch.WindowsSelectorImpl@4e41089d
2017-05-26 11:55:43 DEBUG DefaultChannelId:76 - -Dio.netty.processId: 1080 (auto-detected)
2017-05-26 11:55:43 DEBUG NetUtil:76 - -Djava.net.preferIPv4Stack: false
2017-05-26 11:55:43 DEBUG NetUtil:76 - -Djava.net.preferIPv6Addresses: false
2017-05-26 11:55:43 DEBUG NetUtil:86 - Loopback interface: lo (Software Loopback Interface 1, 127.0.0.1)
2017-05-26 11:55:43 DEBUG NetUtil:81 - Failed to get SOMAXCONN from sysctl and file \proc\sys\net\core\somaxconn. Default: 200
2017-05-26 11:55:43 DEBUG DefaultChannelId:76 - -Dio.netty.machineId: 00:00:00:00:00:00:00:e0 (auto-detected)
2017-05-26 11:55:43 DEBUG ResourceLeakDetectorFactory:76 - Loaded default ResourceLeakDetector: io.netty.util.ResourceLeakDetector@51e93b11
2017-05-26 11:55:43 DEBUG SslHandler:81 - [id: 0x3703659b, L:/192.168.57.232:57300 - R:api.development.push.apple.com/17.188.138.73:443] HANDSHAKEN: TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
2017-05-26 11:55:43 INFO  ApnsClient:429 - Connected to api.development.push.apple.com/17.188.138.73:443.
2017-05-26 11:55:43 TRACE ApnsClientHandler:371 - Received settings from APNs gateway: {HEADER_TABLE_SIZE=4096, MAX_CONCURRENT_STREAMS=1000, MAX_FRAME_SIZE=16384, MAX_HEADER_LIST_SIZE=8000}
2017-05-26 11:55:43 TRACE ApnsClientHandler:169 - Wrote headers on stream 1: DefaultHttp2Headers[:method: POST, :authority: api.development.push.apple.com, :path: /3/device/70....cf27a2ca3abd2f7813da362f38cbd35a876068c22de984d6958af6f27e, apns-expiration: 0, apns-priority: 10, apns-topic: com.ceesoft.ceeview.mobile]
2017-05-26 11:55:43 TRACE ApnsClientHandler:176 - Wrote payload on stream 1: {"aps":{"alert":{"body":"This is a pushy notification!"}}}
2017-05-26 11:55:44 TRACE ApnsClientHandler:332 - Received headers from APNs gateway on stream 1: DefaultHttp2Headers[:status: 400, apns-id: E2F7B914-1E90-9EB9-84AD-55C957A4BA95]
2017-05-26 11:55:44 TRACE ApnsClientHandler:292 - Received data from APNs gateway on stream 1: {"reason":"BadDeviceToken"}
Notification rejected by the APNs gateway: BadDeviceToken
2017-05-26 11:55:44 INFO  ApnsClient:605 - Disconnecting.
--- DONE ---
2017-05-26 11:55:46 DEBUG PoolThreadCache:81 - Freed 23 thread-local buffer(s) from thread: nioEventLoopGroup-3-1

My test program:
----------------------------------------------------------------------------------------------------------------------------------------------

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.ExecutionException;

import javax.net.ssl.SSLException;

import org.apache.log4j.Logger;

import com.turo.pushy.apns.ApnsClient;
import com.turo.pushy.apns.ApnsClientBuilder;
import com.turo.pushy.apns.ClientNotConnectedException;
import com.turo.pushy.apns.PushNotificationResponse;
import com.turo.pushy.apns.auth.ApnsSigningKey;
import com.turo.pushy.apns.util.ApnsPayloadBuilder;
import com.turo.pushy.apns.util.SimpleApnsPushNotification;
import com.turo.pushy.apns.util.TokenUtil;

import io.netty.util.concurrent.Future;

public class TestPushy
{
private static Logger logger = Logger.getLogger(TestPushy.class);
public static void main(String[] args)
{
logger.debug("Starting....");
ApnsClient apnsClient = null;

try
{
InputStream certDev = TestPushy.class.getResourceAsStream("/PushCertificates.p12");
apnsClient = new ApnsClientBuilder()
.setClientCredentials(certDev, "p12-file-password")
       .build();
//File p8file = new File("/path/to/key.p8");
File p8file = new File(TestPushy.class.getResource("/APNsAuthKey_25RFVVWKLV.p8").getFile());
// apnsClient = new ApnsClientBuilder()
//        .setSigningKey(ApnsSigningKey.loadFromPkcs8File(p8file,
//                "488...MCWY", "25R...WKLV"))
//        .build();
final Future<Void> connectFuture = apnsClient.connect(ApnsClient.DEVELOPMENT_APNS_HOST);
connectFuture.await();
final SimpleApnsPushNotification pushNotification;

       {
           final ApnsPayloadBuilder payloadBuilder = new ApnsPayloadBuilder();
           payloadBuilder.setAlertBody("This is a pushy notification!");

           String devToken = "<70....cf27a2ca3abd2f7813da362f38cbd35a876068c22de984d6958af6f27e>";
           
           final String payload = payloadBuilder.buildWithDefaultMaximumLength();
           final String token = TokenUtil.sanitizeTokenString(devToken);

           pushNotification = new SimpleApnsPushNotification(token, "com.ceesoft.ceeview.mobile", payload);
       }

       // Like connecting, sending notifications is an asynchronous process.
       // We'll get a Future immediately, but will need to wait for the Future
       // to complete before we'll know whether the notification was accepted
       // or rejected by the APNs gateway.
       final Future<PushNotificationResponse<SimpleApnsPushNotification>> sendNotificationFuture =
               apnsClient.sendNotification(pushNotification);

       
       final PushNotificationResponse<SimpleApnsPushNotification> pushNotificationResponse =
                    sendNotificationFuture.get();

            if (pushNotificationResponse.isAccepted()) {
                // Everything worked! The notification was successfully sent to
                // and accepted by the gateway.
            } else {
                // Something went wrong; this should be considered a permanent
                // failure, and we shouldn't try to send the notification again.
                System.out.println("Notification rejected by the APNs gateway: " +
                        pushNotificationResponse.getRejectionReason());

                if (pushNotificationResponse.getTokenInvalidationTimestamp() != null) {
                    // If we have an invalidation timestamp, we should also stop
                    // trying to send notifications to the destination token (unless
                    // it's been renewed somehow since the expiration timestamp).
                }
            }
       
}
catch (SSLException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
catch (ExecutionException e)
{
// Something went wrong when trying to send the notification to the
            // APNs gateway. The notification never actually reached the gateway,
            // so we shouldn't consider this a permanent failure.
            System.err.println("Failed to send push notification.");
            e.printStackTrace();

            if (e.getCause() instanceof ClientNotConnectedException) {
                // If we failed to send the notification because the client isn't
                // connected, we can wait for an automatic reconnection attempt
                // to succeed before sending more notifications.
                try
{
apnsClient.getReconnectionFuture().await();
}
catch (InterruptedException e1)
{
// TODO Auto-generated catch block
e1.printStackTrace();
}
            }
}
catch (Exception e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
if (apnsClient != null) {
final Future<Void> disconnectFuture = apnsClient.disconnect();
       try
{
disconnectFuture.await();
}
catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
System.out.println("--- DONE ---");
}

}

Jon Chambers

unread,
May 26, 2017, 9:02:32 AM5/26/17
to Carstein Seeberg, pushy
Is it possible you're trying to send a push notification to a production device token from the development APNs environment?

-Jon

--
Pushy is an open-source Java library for sending APNs (iOS and OS X) push notifications. Pushy is brought to you by the engineers at RelayRides.
---
You received this message because you are subscribed to the Google Groups "pushy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Carstein Seeberg

unread,
May 26, 2017, 9:28:41 AM5/26/17
to pushy, carstein...@gmail.com
Hi Jon,

Thanks for a quick response.

As I mentioned (in my rather large question), I was successful in pushing towards the same device token and cert from the python/django driven http://www.pushwatch.com/apns/
I changed the ApnsClient to hit PRODUCTION_APNS_HOST instead and ended up with a GOAWAY, stating BadCertificateEnvironment.

Carstein
To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+...@googlegroups.com.

Jon Chambers

unread,
May 26, 2017, 12:15:45 PM5/26/17
to Carstein Seeberg, pushy
My guess is that pushwatch.com is using the old "binary" protocol, which may detect bad tokens differently than the newer HTTP/2-based API. If you'd like to test the hypothesis, you could try using an older version of Pushy (v0.4.3 was the last to use the old binary protocol).

Otherwise, all I can tell you is that Pushy is, indeed, connecting to the server and sending the notification. We're getting a well-formed reply from the server that's telling us that the device token is bogus, so I'm confident this isn't something Pushy is doing wrong. I acknowledge that it's surprising that you'd get different results from different providers, but that's also far from the strangest difference we've seen between APNs protocols/environments.

I understand your core question to be "why is the server rejecting my notification?" Regrettably, you know as much as we do ;)

-Jon

To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+unsubscribe@googlegroups.com.

Carstein Seeberg

unread,
May 31, 2017, 5:01:06 PM5/31/17
to pushy, carstein...@gmail.com
Hi Jon,

I have successfully implemented my FCM and APNS push service using your wonderful library.  
The issue was as you initially pointed out, related to certificates and build settings for development/production.
And the reason it worked with pushwatch.com was that it tries both production and development gateways :-)

Thanks again,
Carstein

Jon Chambers

unread,
May 31, 2017, 5:14:59 PM5/31/17
to Carstein Seeberg, pushy
Ah—good to know! Thanks for following up, and I'm glad the issue is resolved.

-Jon

To unsubscribe from this group and stop receiving emails from it, send an email to pushy-apns+unsubscribe@googlegroups.com.

Manasa Salla

unread,
Aug 24, 2020, 8:40:08 AM8/24/20
to pushy
Hi,

Am facing the similar issue of "BadDeviceToken" always , but I have few clarifications, do we need to convert the device token to hexadecimal before sending it to pushy or we just need to send it as is..meaning

String token = "C47C16CF12FFA96A9A0276D32******F6D37F264D715A3BFF1491C13B"
SimpleApnsPushNotification pushNotification  = new SimpleApnsPushNotification(token, "com.att.*****", payload);

We are using the same certificate for DEV/PROD previously with java apns and now migrating to http2 using pushy.

Any clue why its failing on sandbox.

Thanks,
Manasa
Reply all
Reply to author
Forward
0 new messages