Use AWS issued certificate for spring boot app

Tags: , , ,



I have an app running on AWS that has got a React JS front-end hosted through S3 and spring-boot back-end hosted on EC2 instances behind a load balancer. I got my SSL certificate for my domain and I use CloudFront to redirect HTTP requests into HTTPS.

My issue is that I can connect through HTTPS to my load balancer, however, my spring-boot API won’t accept HTTPS from the load balancer. Therefore I use HTTP and anytime I send an API call to my backend, my site changes to Not Secured.

Is there a way to use the Amazon issued certificate in my spring-boot API in order for it to accept HTTPS calls? I have only found tutorials using Self-signed certs and was wondering if I can use my AWS certificate instead.

If there is a way, could you please provide an example of code I need to insert in my application.properties file?

Cheers
Kris

Answer

This part of your question is really confusing, since you don’t provide details about what you mean:

My issue is that I can connect through HTTPS to my load balancer,
however, my spring-boot API won’t accept HTTPS from the load balancer.

Your load balancer should be serving the AWS ACM SSL certificate. You should code your application so that your website makes SSL calls to your API. The load balancer should communicate with your Spring Boot backend server over HTTP, by setting the HTTP protocol and port in the load balancer target group settings.

The traffic flow should look like this:

Web Browser -> (HTTPS) API call to Load Balancer -> (HTTP) call to backend Spring Boot server



Source: stackoverflow