Konstantin Smolyakov
Konstantin Smolyakov

Reputation: 755

How to create an APNS sandbox channel in Amazon Pinpoint?

I have an APNS sandbox certificate as a .p12 file and a password. I see no way to upload it using the AWS Console. There is a method documented in the CLI that should allow it:

https://docs.aws.amazon.com/cli/latest/reference/pinpoint/update-apns-sandbox-channel.html

However, it needs a certificate and private key as separate string parameters. I've tried to separate them using OpenSSL, however each time I get the following error message:

An error occurred (BadRequestException) when calling the UpdateApnsChannel operation: The certificate provided is not a valid Apple certificate

Is there a way to use sandbox certificate with Amazon Pinpoint?

Upvotes: 2

Views: 790

Answers (1)

Konstantin Smolyakov
Konstantin Smolyakov

Reputation: 755

Finally, I was able to do it by hijacking AJAX requests in AWS console when trying to upload a certificate. The JSON body contains privateKey and certificate parameters that can be used with a CLI command.

aws pinpoint update-apns-sandbox-channel --cli-input-json "file://path-to-request-object.json"

The request object file looks like this:

{
  "APNSSandboxChannelRequest": {
    // Both certificate and private key are copied from AJAX request from AWS console
    "Certificate": "-----BEGIN CERTIFICATE-----\n......\n-----END CERTIFICATE-----\n",
    "PrivateKey": "-----BEGIN PRIVATE KEY-----\n.....\n-----END PRIVATE KEY-----\n"
    "Enabled": true
  },
  "ApplicationId": "app-id-here"
}

Upvotes: 3

Related Questions