1

I want to update the APNs channel of an AWS pinpoint application. For that I have to create a APNSChannelRequest with the SSL certificate and the certificate password. The type of the both elements must be a string.

How can I convert the .p12-file to a string or how can I export the right key out of the .p12-file? (This step can be done manually and does't have to be done at runtime.)

Here is the (slightly extended) example of the developer guide from AWS SDK for Java:

APNSChannelRequest request = new APNSChannelRequest()
    .withEnabled(enabled);

UpdateApnsChannelRequest updateRequest = new UpdateApnsChannelRequest()
    .withCertificate("here comes the ssl-certificate string")
    .withPrivateKey("pw123")
    .withAPNSChannelRequest(request)
    .withApplicationId("placeholder-for-the-appId");
UpdateApnsChannelResult result = client.updateApnsChannel(updateRequest);        

I can't find anything in the documentation.

Thanks for your help.

Philissimo
  • 11
  • 2

1 Answers1

0

This will require converting the contents of the p12 file to PEM format. This can be achieved via the command line using openssl as follows:

openssl pkcs12 -in certificate.p12 -nodes -clcerts 

This will result in the CERTIFICATE and PRIVATE KEY values to be emitted in base64 format. Supply the string beginning with: "-----BEGIN CERTIFICATE-----" and ending with "-----END CERTIFICATE-----" as the Certificate value in the UpdateApnsChannelRequest. Supply the string beginning with "-----BEGIN PRIVATE KEY-----" and ending with "-----END PRIVATE KEY-----" as the PrivateKey value in the UpdateApnsChannelRequest.

double-beep
  • 5,031
  • 17
  • 33
  • 41