Search code examples
amazon-web-servicesamazon-ec2aws-security-groupaws-application-load-balanceraws-elb

AWS ELB causing net::ERR_CERT_COMMON_NAME_INVALID error


Currently getting the net::ERR_CERT_COMMON_NAME_INVALID when trying to access my application through the ALB.

This is my current setup:

  • SSL Certificate created that covers example.com & *.example.com using AWS Certificate Manager.
  • 2 server ec2 instances behind a load balancer and 2 client instances behind another load balancer.
  • An alias record in my Route 53 hosted zone pointing to the client ALB.
  • Both ALBs have the SSL certificate for example.com attached to them.
  • Both ALBs have a single HTTPS: 443 listener forwarding https traffic to ec2 instances on port 80.
  • The server ALB security group allows inbound traffic from the client ALB Security Group and outbound to the server instances security group.
  • The applications in the client ec2 instances are React Apps pointing to the server ALB at https://xxxxxxxxxx.elb.amazonaws.com/api

Accessing the application via https://example.com causes net::ERR_CERT_COMMON_NAME_INVALID in the console with the browser saying:

Error: The certificate for this server is invalid. You might be connecting to a server that is pretending to be “xxxxxxxxxx.elb.amazonaws.com” which could put your confidential information at risk.

I'd be happy to provide more details if it helps.


Solution

  • If you have your own domain example.com with correct SSL certificate then you can't use https://xxxxxxxxxx.elb.amazonaws.com/api which is AWS domain. The reason is that SSL cert is for example.com, not for https://xxxxxxxxxx.elb.amazonaws.com/api.

    You have to modify your application code to only use example.com.