Note that there are some explanatory texts on larger screens.

plurals
  1. POgetting an exception when trying to initialize ApnsServiceBuilder
    primarykey
    data
    text
    <p>I need a <code>.p12</code> file in order to authenticate with Apple's notification servers, and I have found some problems. As I understand, I need to generate the .csr and my private key identifying my machine. So I need to execute a command like this in my local machine:</p> <pre><code>*$:~/Escritorio/curro/certificados$ openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout privateKey.key Generating a 2048 bit RSA private key </code></pre> <p>writing new private key to 'privateKey.key'</p> <p>Now, with my CSR.csr file, I need to login in to:</p> <pre><code>https://developer.apple.com/account/ios/certificate/certificateCreate.action?formID=62653259 </code></pre> <p>then I provide the .csr file generated before and the system gives me a .cer file (aps_development.cer) . Now, with this .cer file I have to generate it .p12 equivalent file. In order to do that, I need to make a .pem file starting from that .cer generated file from Apple. This is the command:</p> <pre><code>@Ubuntu:~/Escritorio/curro/certificados$ openssl pkcs12 -export -inkey privateKey.key -in developer_identity.pem -out iphone_dev.p12 Enter Export Password: Verifying Enter Export Password: </code></pre> <p>After that I have a .p12 file and I need to initialize an ApnsService instance,</p> <pre><code>@Component public class NotificationServer implements Runnable, BeanFactoryAware { @Autowired // APNS channel private ApnsService serviceApns; private String apns_payload; @PostConstruct public void init() { // build apns service path_to_apns_certificate, absolute path .p12 file String path_to_apns_certificate = config.getProperty("a-path"); //pass used to generate the .p12 file String password_apns_cert = config.getProperty("a-path"); log.debug("path_to_apns_certificate: " + path_to_apns_certificate); //keep an eye with this!, this builder is non thread safe! ApnsServiceBuilder apnsbuilder = new ApnsServiceBuilder(); String sMaxConections = config.getProperty("maxConections"); log.debug("sMaxConections: " + sMaxConections); int maxConections = Integer.parseInt(sMaxConections); apnsbuilder.asPool(maxConections ); String connectWithAppleApns = config.getProperty("apns.production"); log.debug("connectWithAppleApns: " + connectWithAppleApns); apnsbuilder.withAppleDestination(new Boolean(connectWithAppleApns)); //here the exception is launched! apnsbuilder.withCert(path_to_apns_certificate, password_apns_cert); serviceApns =apnsbuilder.build(); } } </code></pre> <p><strong>Here is the error message:</strong></p> <pre><code>Caused by: com.notnoop.exceptions.InvalidSSLConfig: java.io.IOException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded at com.notnoop.apns.internal.Utilities.newSSLContext(Utilities.java:88) at com.notnoop.apns.ApnsServiceBuilder.withCert(ApnsServiceBuilder.java:167) at com.notnoop.apns.ApnsServiceBuilder.withCert(ApnsServiceBuilder.java:134) at com.*****.agenda.utils.NotificationServer.init(NotificationServer.java:122) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:606) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:346) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:299) at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:132) ... 164 more Caused by: java.io.IOException: failed to decrypt safe contents entry: javax.crypto.BadPaddingException: Given final block not properly padded at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1304) at java.security.KeyStore.load(KeyStore.java:1214) at com.notnoop.apns.internal.Utilities.newSSLContext(Utilities.java:85) ... 174 more Caused by: javax.crypto.BadPaddingException: Given final block not properly padded at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:811) at com.sun.crypto.provider.CipherCore.doFinal(CipherCore.java:676) at com.sun.crypto.provider.PKCS12PBECipherCore.implDoFinal(PKCS12PBECipherCore.java:355) at com.sun.crypto.provider.PKCS12PBECipherCore$PBEWithSHA1AndRC2_40.engineDoFinal(PKCS12PBECipherCore.java:462) at javax.crypto.Cipher.doFinal(Cipher.java:2087) at sun.security.pkcs12.PKCS12KeyStore.engineLoad(PKCS12KeyStore.java:1295) ... 176 more </code></pre> <p>Can anyone give my any perspective on this?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload