. Advertisement .
..3..
. Advertisement .
..4..
I get the “bad request this combination of host and port requires TLS” error as the title says. How can I fix it so the error goes away? Here is my detail:
http://localhost:8081/points/12345/search
server.ssl.key-store=classpath:KeyStore.jks
server.ssl.key-store-password=test
@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);
}
}
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
When I operated it, I received the error text:
Could not get any response
There was an error connecting to https://localhost:8081/points/12345/search.
I appreciate any help from you.
The cause:
The error has as a server certificate is being used instead of a client certificate. The problem was that the application already had
https
set as its default protocol, but you were calling it usinghttp
in the browser.Solution:
The simple solution is that:
At the beginning, used
https://
instead ofhttp://
This message was sent to me because I used the wrong certificate.
I misunderstood Server certificate and Client certificate.
In my case, although I had installed my certificate on the server for my domain, what I really needed was to use it as a client certificate to make the request.
You can see how it is done here.
Client Certificate Authentication With Spring Boot
This message basically says: “Hey! Your SSL request isn’t OK”, or I can’t locate the cert file. As @SerdarAtalay states, it could also signify that you didn’t use the
https://
prefix.We hope it helps!