Spring App on GCP - Cloud Run - HTTPS only - This combination of host and port requires TLS

Viewed 305

My Spring app uses lets encrypt and is https only. I did not include http to https thing, as it worked for me in postman with https:// format

When I deployed to Cloud Run, and mentioned the custom port (the port specified in spring) and tested using URL from dashboard

https://..blah..run.app

I am getting error/message

Bad Request This combination of host and port requires TLS.

What configuration is required on Cloud Run to resolve this?

The url as I see on service details page has htpps://... enter image description here

EDIT: If Cloudrun does not need me to take case of SSL, I can remove the application properties entries

server.ssl.key-store-type=PKCS12
server.ssl.key-store=classpath:key/keystore.p12
server.ssl.key-store-password=${lets.secret}
server.ssl.key-alias=someCertAlias
server.ssl.enabled=true

So Can I get an answer on whether to remove SSL from spring? If cloudrun always uses http, all my calls use redirectConnector, which seems pointless

1 Answers

The Cloud Run Service listens on HTTP and HTTPS. Your application running in the container must listen on a port configured with HTTP only.

FYI: For a public facing web server, you should almost always enable HTTP. Otherwise, when a user enters www.example.com in the browser, the user will receive a connect error. This not always the case, for example .dev gTLDs, but is good practice. When a user connects to Cloud Run with the HTTP protocol, Cloud Run will redirect the user to HTTPS and connect to your application using the HTTP protocol.

Related