Misha Zaslavsky
Misha Zaslavsky

Reputation: 9702

AWS ELB SSL returns "The private key did not match the public key provided"

I got the PEM files (with openssl) in order to paste them in AWS ELB for https protocol.

In AWS in "Select Certificate" window I paste: Screenshot - select certificate

  1. Private Key: private.pem which starts with -----BEGIN RSA PRIVATE KEY-----
  2. Public Key Certificate: public.pem which starts with -----BEGIN CERTIFICATE-----
  3. Certificate Chain: Empty

When I Saves it I receive:

Screenshot - Updating Listeners Failed

Can you help me to figure out what am I doing wrong?

Upvotes: 1

Views: 8376

Answers (1)

Monis
Monis

Reputation: 1008

There seems to be a mismatch in public-private key pair. Also, AWS recommends to have a certificate chain, otherwise it will consider the server as an unverified SSL.
Seems like you have to regenerate your SSL certificate.

For this you can do the following:-

1. Create SSL private key using OPENSSL.

sudo openssl genrsa -out your-private-key-name.pem 2048

2. Next, create a CSR key using OPEN-SSL

openssl req -sha256 -new -key your-private-key-name.pem -out csr.pem

The system will ask for some details, like your country, city, company name etc. Fill in those details.

  1. These steps will result in two .pem files.

  2. Now, while generating your SSL certificate from your SSL provider, generate the SSL certificate using the csr.pem contents.

  3. After verification, you will be provided with your SSL certificate (.crt) files. [Generally, two .crt files]

  4. Now, you have to configure this configuration onto AWS server.

  5. Open the form (for which you have posted the screenshot).
    a. For private key section, post the contents of your-private-key-name.pem
    b. Open one of the .crt files with a text editor. If this has only one set of
    -----BEGIN CERTIFICATE----- AND -----END CERTIFICATE-----
    paste it in the Public Key Certificate section.

    c. If the .crt file has multiple sets of
    -----BEGIN CERTIFICATE----- AND -----END CERTIFICATE-----
    paste it in the Certificate Chain section.

Now, you have entered your Private Key, Public Key and Certificate Chain AWS should not give any error.

NOTE: If you have not purchased a certificate, and are using a self-signed certificate, you can skip the steps (4), (5), (7)-c and leave the Certificate Chain blank.

Hope that helps.

EDIT

Do not copy the contents of .pem and .crt files directly from LINUX (vi editor). Open the files in windows and then paste the contents into the AWS form. I had a similar issue and this was what i was doing wrong.

Upvotes: 3

Related Questions