Is anyone knows how to secure the rest endpoints with https?

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Is anyone knows how to secure the rest endpoints with https?

ankit8051
I have configure the ratpack with spring boot, so i have tomcat is running on 8080 and netty(ratpack) server is running on 5050.

How i can configure ratpack server use https instead of http?

Reply | Threaded
Open this post in threaded view
|

Re: Is anyone knows how to secure the rest endpoints with https?

Luke Daley
Administrator

You need to set an SSLContext on the server config.


e.g.

ratpack {
  serverConfig {
    ssl SSLContexts.sslContext(new File(“keystore.jks”), “password”)
  }
}
rus
Reply | Threaded
Open this post in threaded view
|

Re: Is anyone knows how to secure the rest endpoints with https?

rus
I'm not completely au-fait with our spring boot integration but this doesn't appear to be exposed by `ratpack.spring.config.RatpackProperties`.  I think you will need to add a ratpack.spring.config.RatpackServerCustomizer and do this in the getServerConfig method where you will have access to ratpack.server.ServerConfigBuilder.

Or define your own ratpack.server.ServerConfig bean as it's declared as @ConditionalOnMissingBean.  So if you provide your own that will take precedence.
Reply | Threaded
Open this post in threaded view
|

Re: Is anyone knows how to secure the rest endpoints with https?

ankit8051
Thanks,

If you have any example then please share it with me, it will be better.
rus
Reply | Threaded
Open this post in threaded view
|

Re: Is anyone knows how to secure the rest endpoints with https?

rus
There are a few ways to do this but essentially you need to register a bean of type RatpackServerCustomizer

    @Bean
    RatpackServerCustomizer ratpackServerCustomizer() {
      return new SSLServerCustomizer();
    }

Where SSLServerCustomizer extends RatpackServerCustomizerAdapter

    protected static class SSLServerCustomizer extends RatpackServerCustomizerAdapter {
    @Override
    public Action<ServerConfigBuilder> getServerConfig() {
      return serverConfigBuilder -> serverConfigBuilder.ssl(........);
    }
  }

HTH