getting an exception when trying to initialize ApnsServiceBuilder

aironman

I need a .p12 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:

*$:~/Escritorio/curro/certificados$ openssl req -out CSR.csr -new -newkey rsa:2048 -nodes -keyout privateKey.key
Generating a 2048 bit RSA private key

writing new private key to 'privateKey.key'

Now, with my CSR.csr file, I need to login in to:

https://developer.apple.com/account/ios/certificate/certificateCreate.action?formID=62653259

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:

@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:

After that I have a .p12 file and I need to initialize an ApnsService instance,

@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();       
}
}

Here is the error message:

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

Can anyone give my any perspective on this?

aironman

I response myself. That error involves an error with the pass or the user, in my case the pass that was saved with quotes!! days without seen that mistake.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

getting an exception when trying to initialize ApnsServiceBuilder

From Dev

getting Socket Exception 10054 when trying to socket.Connect

From Dev

Trying to get the _id when an item in gridview is clicked getting a cast exception

From Dev

Why i'm getting "titlebarViewController not supported for this window style" exception when trying to add title bar accessory view

From Dev

Why am I getting this IllegalArgumentException exception when trying to inject services into an actor?

From Dev

Getting a Null Pointer Exception when I am trying to start PySpark

From Dev

getting library_error exception when trying to use boost::interprocess::message_queue

From Dev

Getting Exception when trying to get pattern data using loop

From Dev

Getting Connection closed Exception when trying to connect to PostgreSQL DB with JHipster Application

From Dev

Trying to avoid this error (raise exception KeyError: 'text') , when getting tweets about verizon

From Dev

getting @autowired intance null when try trying to do operation on it,throwing null pointer exception

From Dev

Getting null pointer exception when trying to merge sort array of a class

From Dev

Getting nullpointer exception when trying to mock package private method using powermockito

From Dev

Getting nullpointer exception when trying to mock package private method using powermockito

From Dev

getting library_error exception when trying to use boost::interprocess::message_queue

From Dev

getting Socket Exception 10054 when trying to socket.Connect

From Dev

Getting null pointer exception when trying to add data from sqlite to spinner

From Dev

Getting Null Pointer Exception when trying to get the value from global variable

From Dev

Why i'm getting "titlebarViewController not supported for this window style" exception when trying to add title bar accessory view

From Dev

Getting exception when trying to delete a line from a text file. How can i solve it?

From Dev

Why i'm getting Win32Exception when trying to get info from process inside a backgroundworker?

From Dev

Trying to initialize Quill with specific formats and getting an error

From Dev

Why am I getting this IllegalArgumentException exception when trying to inject services into an actor?

From Dev

Getting a Null reference exception when trying to pass datable from one form to another

From Dev

why am i getting null pointer exception when trying to set a value to "rating" in my rating bar?

From Dev

Getting PDF_VALIDATION_FAILED exception when trying to create envelopne in DocuSign sample recipe code

From Dev

Trying to avoid this error (raise exception KeyError: 'text') , when getting tweets about verizon

From Dev

I am getting null pointer exception when I an trying to putExtra from intent

From Dev

Why am I getting an "invalid aggregate" error when trying to initialize this record in VHDL?

Related Related

  1. 1

    getting an exception when trying to initialize ApnsServiceBuilder

  2. 2

    getting Socket Exception 10054 when trying to socket.Connect

  3. 3

    Trying to get the _id when an item in gridview is clicked getting a cast exception

  4. 4

    Why i'm getting "titlebarViewController not supported for this window style" exception when trying to add title bar accessory view

  5. 5

    Why am I getting this IllegalArgumentException exception when trying to inject services into an actor?

  6. 6

    Getting a Null Pointer Exception when I am trying to start PySpark

  7. 7

    getting library_error exception when trying to use boost::interprocess::message_queue

  8. 8

    Getting Exception when trying to get pattern data using loop

  9. 9

    Getting Connection closed Exception when trying to connect to PostgreSQL DB with JHipster Application

  10. 10

    Trying to avoid this error (raise exception KeyError: 'text') , when getting tweets about verizon

  11. 11

    getting @autowired intance null when try trying to do operation on it,throwing null pointer exception

  12. 12

    Getting null pointer exception when trying to merge sort array of a class

  13. 13

    Getting nullpointer exception when trying to mock package private method using powermockito

  14. 14

    Getting nullpointer exception when trying to mock package private method using powermockito

  15. 15

    getting library_error exception when trying to use boost::interprocess::message_queue

  16. 16

    getting Socket Exception 10054 when trying to socket.Connect

  17. 17

    Getting null pointer exception when trying to add data from sqlite to spinner

  18. 18

    Getting Null Pointer Exception when trying to get the value from global variable

  19. 19

    Why i'm getting "titlebarViewController not supported for this window style" exception when trying to add title bar accessory view

  20. 20

    Getting exception when trying to delete a line from a text file. How can i solve it?

  21. 21

    Why i'm getting Win32Exception when trying to get info from process inside a backgroundworker?

  22. 22

    Trying to initialize Quill with specific formats and getting an error

  23. 23

    Why am I getting this IllegalArgumentException exception when trying to inject services into an actor?

  24. 24

    Getting a Null reference exception when trying to pass datable from one form to another

  25. 25

    why am i getting null pointer exception when trying to set a value to "rating" in my rating bar?

  26. 26

    Getting PDF_VALIDATION_FAILED exception when trying to create envelopne in DocuSign sample recipe code

  27. 27

    Trying to avoid this error (raise exception KeyError: 'text') , when getting tweets about verizon

  28. 28

    I am getting null pointer exception when I an trying to putExtra from intent

  29. 29

    Why am I getting an "invalid aggregate" error when trying to initialize this record in VHDL?

HotTag

Archive