Thứ Ba, 14 tháng 2, 2017

Generate APNS p12

  1. Export the private key from the Keychain and name it aps_private-key.p12.
  2. Convert the key with the following command openssl pkcs12 -nocerts -out aps_private-key.pem -in aps_private-key.p12, make sure to enter a PEM pass phrase of at least 4 characters.
  3. Download the certificate for your app from https://developer.apple.com/account/ios/identifiers/bundle/bundleList.action. The downloaded file should be called something like aps_development.cer.
  4. Convert the certificate with the following command openssl x509 -in aps_development.cer -inform der -out aps_development.pem
  5. Generate the credentials using openssl pkcs12 -export -in aps_development.pem -out aps_dev_credentials.p12 -inkey aps_private-key.pem.
  6. And I'm ready to use the credentials generated in step 5 (aps_dev_credentials.p12).
    final InputStream certificate = Thread.currentThread().getContextClassLoader()
            .getResourceAsStream("aps_dev_credentials.p12");
    final char[] passwd = {'1','2','3','4'};
    final ApnsService apnsService = com.notnoop.apns.APNS.newService()
            .withCert(certificate, new String(passwd))
            .withSandboxDestination().build();
    apnsService.testConnection();

Source: http://stackoverflow.com/questions/20077626/whats-the-correct-format-for-java-apns-certificate

Không có nhận xét nào:

Đăng nhận xét