Java APNS Certificate Error with DerInputStream.getLength(): lengthTag=109, too big.
I had the same problem but my solution will help you only if you are using maven.
Maven resource filtering (that let's you include variables in your resource files) can mess up your binaries - and certificates are especially sensitive to modification.
In general, binary content shouldn't be filtered. But I couldn't just simply disable resource filtering because I have some .properties files that include variables. So the solution was to exclude .p12 files from filtering.
<build>
[...]
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<excludes>
<exclude>**/*.p12</exclude>
</excludes>
</resource>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
<includes>
<include>**/*.p12</include>
</includes>
</resource>
</resources>
[...]
</build>
More about maven resource filtering:
http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html
PKCS#12 : DerInputStream.getLength() exception
I had this problem and I've searched the depths of google and still couldn't find the answer. After some days battling with a terrible quality legacy code, I found what was causing this error.
KeyStore.load(InputStream is, String pass);
this method takes an InputStream and if there's any problem with such InputStream, this exception is thrown, some problems that I've encountered:
- The InputStream points to the wrong / blank / just created file
- The InputStream is already open or something else is holding the resource
- The InputStream was already used and read, thus the position of the next byte of InputStream is it's end
The last one was the responsible for my problem. The code was creating an InputStream from a certificate, and proceeding to use it in two KeyStore.load() calls, the first one was successful, the second one always got me this error.
grails apns plugin : SSLHandshakeException
It was a certificate issue , after generating another .p12 file it finally worked :)
Related Topics
Sha256Withrsa What Does It Do and in What Order
Rselenium Unknownerror - Java.Lang.Illegalstateexception with Google Chrome
Install Xlsx and Rjava on MACos Mavericks 10.9.5
Reading a Jsp Variable from JavaScript
Converting a Java Arraylist of Strings to a JavaScript Array
Call External JavaScript Functions from Java Code
What's the Equivalent of Java's Thread.Sleep() in JavaScript
Jsoup Get Dynamically Generated HTML
Convert Encrypt Code in Java to Ruby
Java Client and a C++ Server Send and Receive via Tcp Socket
Why Ruby Modulo Is Different from Java/Other Lang
How to Get from Jruby a Correctly Typed Ruby Implementation of a Java Interface
Fixing 'Path' in Environment Variables in Windows 7 for Multiple Applications