How to Install an SSL Certificate on AWS (EC2, ALB and ACM)

Summarize this article with AI:

Table of Contents

On AWS you rarely install a certificate on the EC2 instance itself. You import the PEM files into AWS Certificate Manager, then attach that certificate to a load balancer's HTTPS listener. The instance can keep serving plain HTTP behind it. If you have no load balancer, install the files on the web server.

Where Does an SSL Certificate Go on AWS?

AWS offers three places. The load balancer ends the HTTPS connection, which is the common choice. CloudFront does the same at the edge. Or the web server on the instance holds the files itself, as it would on any Linux host.

PlaceCertificate lives inUse it when
Application Load BalancerACM or IAMYou run one or more instances behind a load balancer
CloudFrontACM, in us-east-1You serve a site or app through the CDN
The EC2 instanceFiles on the serverOne instance, no load balancer, or you need end-to-end TLS

A load balancer decrypts traffic and forwards it to targets, as the AWS listener guide explains. A load balancer therefore needs the certificate, and the targets behind it do not.

What Files Do You Need Before You Start?

You need three PEM files: your certificate, the CA's chain, and the private key. ACM wants the key unencrypted and the certificate valid on the day you import. So DER files, and keys with a passphrase, are rejected right away.

  • Certificate body: your server certificate only, from BEGIN CERTIFICATE to END CERTIFICATE.
  • Certificate chain: the intermediates, in a separate file.
  • Private key: PEM, unencrypted, and no larger than 5 KB.
  • Key type: RSA 2048 or 4096, or an ECDSA curve that your service supports.

These limits come from the ACM import requirements. Application Load Balancers do not support ED25519 keys, so avoid that key type.

How to Create the Key and CSR for AWS

ACM cannot hand you a CSR for a certificate you buy elsewhere. Create the key and CSR yourself with OpenSSL, send the CSR to the certificate authority, and keep the key. Do not use the ACM request command for this.

  1. Run openssl genrsa -out www.example.com.key 2048
  2. Run openssl req -new -key www.example.com.key -out www.example.com.csr
  3. Enter your domain in the Common Name and SAN fields.
  4. Submit the CSR to the CA and wait for the signed files.

The OpenSSL command list shows the extra options. The old guide used an ACM CLI call to export a CSR, but ACM does not issue one.

How to Convert Keys and Certificates into PEM

Most CAs send PEM already. However, if your key starts with BEGIN RSA PRIVATE KEY, convert it first. The same goes for DER or PFX files, so check each file header. We ran each conversion with OpenSSL 3.0.13 on a test certificate.

openssl converting a traditional RSA key to PKCS8 for AWS

Converting a traditional RSA key to the PKCS8 format with OpenSSL 3.0.13, 2 December 2026.

openssl splitting a full chain and converting a DER certificate

Splitting a full chain and converting a DER certificate, tested on 2 December 2026.

A PFX file needs one extra step, because OpenSSL writes Bag Attributes lines above the key. So delete everything before the BEGIN PRIVATE KEY line.

openssl removing Bag Attributes from an extracted key

Removing Bag Attributes from a key extracted from a PFX file, 2 December 2026.

How to Import the Certificate into ACM

Open the ACM console and choose Import a certificate. Paste the certificate body, the unencrypted private key, and the chain. Then choose Import. You can do the same with the AWS CLI by pointing three file options at your PEM files.

aws acm import-certificate --certificate fileb://Certificate.pem --certificate-chain fileb://CertificateChain.pem --private-key fileb://PrivateKey.pem

The command returns the certificate's ARN, as the ACM import guide describes. We did not run it because we had no AWS account, so compare your output with the guide.

How to Attach the Certificate to a Load Balancer

Open the EC2 console, choose Load Balancers, pick yours, and add an HTTPS listener. Select the ACM certificate as the default, choose a security policy, and set the forward action to your target group. Then save the listener, and wait a moment.

  1. Choose Load Balancers, then select the load balancer.
  2. On Listeners and rules, choose Add listener.
  3. Set the protocol to HTTPS and keep port 443.
  4. Pick the forward action and your target group.
  5. Choose the ACM certificate and a security policy, then add the listener.

Allow inbound HTTPS in the load balancer's security group. Then add a rule that redirects port 80 to 443 so visitors never stay on HTTP.

How to Install the Certificate Directly on an EC2 Instance

Without a load balancer, copy the certificate, chain and key to the instance and point your web server at them. Then combine the certificate and chain into one file for Nginx. Also open port 443 in the instance's security group.

  • Nginx: set ssl_certificate to the combined file and ssl_certificate_key to the key.
  • Apache: set SSLCertificateFile, SSLCertificateKeyFile and SSLCertificateChainFile.
  • Reload the server, then test from outside AWS.

We did not run these web server steps on an EC2 instance. They match the standard directives for each server.

How Do You Test the Installation?

Open the site over HTTPS and check the certificate details in the browser. Then run openssl s_client from your own machine to read the served chain. A missing intermediate shows up as an unable-to-verify error, so look for that first.

openssl s_client -connect www.example.com:443 -servername www.example.com

Also check the date, because openssl x509 -noout -checkend 2592000 returned exit code 1 for a test certificate near expiry. So you can use it in a reminder script.

How Do You Renew an Imported Certificate?

ACM does not renew imported certificates for you. So get a new certificate from your CA, then reimport it so the ARN and every attachment stay the same. You must watch the expiry date yourself, for example with EventBridge notices.

Because certificates in ACM are regional, the same guide says to import one into each Region you use. For CloudFront, import it into us-east-1.

What Causes Common AWS SSL Errors?

Most errors come from the same few mistakes. A missing chain, a key with a passphrase, a DER file, or a wrong Region will stop an import. The same mistakes can break trust in the browser. So check these first.

  • Browser says untrusted: the chain is missing or in the wrong file.
  • Import fails: the key is encrypted, or the files are not PEM.
  • Certificate is not listed on the load balancer: it was imported in another Region.
  • Name mismatch: you opened the site by IP, or the domain is not in the SAN.
  • Site is unreachable on HTTPS: port 443 is closed in a security group.

Frequently Asked Questions

Can I use a free certificate on AWS?

Yes. ACM issues free public certificates for use with integrated AWS services. A free certificate from another CA also works if you import it.

Does the EC2 instance need its own certificate behind a load balancer?

No, the load balancer ends the HTTPS connection. Add one only if you want encrypted traffic between the load balancer and the instance.

Can I attach more than one certificate to a load balancer?

Yes. Application Load Balancers keep a certificate list for a listener, so one load balancer can serve several domains.

Does ACM renew a certificate I imported?

No. You get a new certificate from your CA and reimport it before the old one expires.

Why does ACM reject my private key?

The key is probably encrypted, not PEM, or larger than 5 KB. Remove the passphrase and convert it to PEM.