spring-bootssl

Bad Request - This combination of host and port requires TLS. with Spring Boot


I'm newbie with Spring Boot.

I'm trying to make a https call to a service, I have a Privake key to secure connection.

I hit:

http://localhost:8081/points/12345/search

I tried with https:// but I get from Postman:

Could not get any response
There was an error connecting to https://localhost:8081/points/12345/search.

From the moment I wrote

server.ssl.key-store=classpath:KeyStore.jks
server.ssl.key-store-password=test

in application.properties, I get the error message:

Bad Request - This combination of host and port requires TLS

I have deleted all my code in my controller, I just let the endpoint so that I can invoke it.

@RestController
@SpringBootApplication
public class MainApplication {
    @RequestMapping(value = "/points/{point}/search", method = RequestMethod.GET)
    public PointsType getPoint(@PathVariable(value = "point") String point) {
        System.out.println("hi"); // Never printed
        return null;
    }
    public static void main(String[] args) {
        SpringApplication.run(MainApplication.class, args);
    }
}

Here is the file application.properties:

spring.application.name=sge
server.port=8081
server.ssl.key-store=classpath:KeyStore.jks
server.ssl.key-store-password=test
server.ssl.key-alias=homologation-staging
server.ssl.trust-store=classpath:TrustStore.jks
server.ssl.trust-store-password=test
server.ssl.client-auth=need
security.require-ssl=true
server.tomcat.remote_ip_header=x-forwarded-for
server.tomcat.protocol_header=x-forwarded-proto

What should I do ?


Solution

  • I used https:// at the beginning instead of http://, it worked for me.