Safari Push Notifications - Add intermediate certificate to push package signature in Java
<p>I am currently trying to compute the signature required for safari push notifications. This was working until apple changed the signing rules:</p>

<blockquote>
  <p>Important: After February 14, 2016, you will need to sign the push package >with both the web push certificate and the intermediate certificate. The >updated create_signature function in the attached createPushPackage.php >companion file processes both certificates.</p>
</blockquote>

<p>I have been using the BouncyCastle library to implement the this using a CMSSignedDataGenerator. This worked fine for the .p12 web push notification certificate. Now I have the AppleWWDRCA.pem intermediate certificate (converted from AppleWWDRCA.cer) and I have been trying to add the certificate to the existing signed data generator:</p>

<pre><code>CMSSignedDataGenerator generator = new CMSSignedDataGenerator();
</code></pre>

<p>Using:</p>

<pre><code>        CertificateFactory cf = CertificateFactory.getInstance("X.509");
        X509Certificate appleCert = (X509Certificate)cf.generateCertificate(servletContext.getResourceAsStream("/WEB-INF/AppleWWDRCA.pem"));
        JcaCertStore jcaCertStoreApple = new JcaCertStore(Collections.singleton(appleCert));
        generator.addCertificates(jcaCertStoreApple);
</code></pre>

<p>Why is this still giving me the "Signature verification of push package failed." error message?</p>