Class SSLPlugin

java.lang.Object
io.javalin.community.ssl.SSLPlugin
All Implemented Interfaces:
io.javalin.plugin.Plugin

public class SSLPlugin extends Object implements io.javalin.plugin.Plugin
A plugin to easily enable SSL on a Javalin server.

The intended configuration pattern is to use the SSLPlugin(Consumer) constructor to configure the plugin, either though a lambda or a Consumer. This allows for a more fluent configuration pattern.

Hot reloading of the SSL certificates is supported. This means that the plugin will replace the SSL certificates without restarting the server, allowing for a seamless transition. This is done by using the reload(Consumer) method.

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new SSLPlugin with the default configuration.
    Creates a new SSLPlugin with the given configuration.
    Creates a new SSLPlugin with the given configuration lambda/supplier.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    apply(@NotNull io.javalin.Javalin javalin)
    Method to apply the plugin to a Javalin instance
    void
    patch(@NotNull org.eclipse.jetty.server.Server server)
    Method to apply the SSLConfig to a given Jetty Server.
    void
    reload(SSLConfig newConfig)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Use reload(Consumer) instead.
    void
    Method to hot-swap the certificate and key material of the plugin.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • SSLPlugin

      public SSLPlugin()
      Creates a new SSLPlugin with the default configuration.
    • SSLPlugin

      public SSLPlugin(SSLConfig config)
      Creates a new SSLPlugin with the given configuration.
      Parameters:
      config - The configuration to use.
    • SSLPlugin

      public SSLPlugin(Consumer<SSLConfig> config)
      Creates a new SSLPlugin with the given configuration lambda/supplier. This is useful if you want to use the default configuration and only change a few values. Recommended way to create a new SSLPlugin with the given configuration.
      Parameters:
      config - The configuration to use.
  • Method Details

    • apply

      public void apply(@NotNull @NotNull io.javalin.Javalin javalin)
      Method to apply the plugin to a Javalin instance
      Specified by:
      apply in interface io.javalin.plugin.Plugin
      Parameters:
      javalin - Javalin instance
    • patch

      public void patch(@NotNull @NotNull org.eclipse.jetty.server.Server server)
      Method to apply the SSLConfig to a given Jetty Server. Can be used to patch pre-existing or custom servers.
      Parameters:
      server - The Jetty Server to patch.
    • reload

      @Deprecated(forRemoval=true, since="5.3.2") public void reload(SSLConfig newConfig)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Use reload(Consumer) instead.
      Method to hot-swap the certificate and key material of the plugin. Any configuration changes will be ignored, only the certificate and key material will be updated.
      Parameters:
      newConfig - A config containing the new certificate and key material.
    • reload

      public void reload(Consumer<SSLConfig> newConfig)
      Method to hot-swap the certificate and key material of the plugin. Any configuration changes will be ignored, only the certificate and key material will be updated.
      Parameters:
      newConfig - A consumer providing the new certificate and key material.