Reputation: 101
I have web application which use spring social facebook to login via favebook and register new account. I created Self signed certificate SSL and when I input https://localhost:8001/ its redirect me to my login page, but when I click on button "Login with Facebook" I got this error:
Status 400:
Bad Request
This combination of host and port requires TLS.
My social configuration looks like this:
ConnectorConfig class
@Configuration
public class ConnectorConfig {
private static final int HTTP_PORT = 80;
private static final int HTTPS_PORT = 443;
private static final String HTTP = "http";
private static final String USER_CONSTRAINT = "CONFIDENTIAL";
@Bean
public ServletWebServerFactory servletContainer() {
TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() {
@Override
protected void postProcessContext(Context context) {
SecurityConstraint securityConstraint = new SecurityConstraint();
securityConstraint.setUserConstraint(USER_CONSTRAINT);
SecurityCollection collection = new SecurityCollection();
collection.addPattern("/*");
securityConstraint.addCollection(collection);
context.addConstraint(securityConstraint);
}
};
tomcat.addAdditionalTomcatConnectors(redirectConnector());
return tomcat;
}
private Connector redirectConnector() {
Connector connector = new Connector(
TomcatServletWebServerFactory.DEFAULT_PROTOCOL);
connector.setScheme(HTTP);
connector.setPort(HTTP_PORT);
connector.setSecure(false);
connector.setRedirectPort(HTTPS_PORT);
return connector;
}
}
application.properties
spring.thymeleaf.cache=false
server.port=443
server.ssl.key-store-type=PKCS12
server.ssl.key-store=classpath:keystore/baeldung.p12
server.ssl.key-store-password=123456
server.ssl.key-alias=baeldung
trust.store=classpath:keystore/baeldung.p12
trust.store.password=123456
And picutre for settings in facebook for developers site
UPDATE: I set those properties for HTTP and HTTPS but when Spring Bott runs I got that ports 443 and 80 are already in use, but when I change to other port error is the same.
Anyone know how resolve this ? I think that from https://localhost:8001/login app redirect to http instead of https.
Upvotes: 2
Views: 9814