|
|
|
@ -17,6 +17,7 @@ |
|
|
|
package org.springframework.boot.web.embedded.jetty; |
|
|
|
package org.springframework.boot.web.embedded.jetty; |
|
|
|
|
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.io.IOException; |
|
|
|
|
|
|
|
import java.net.InetSocketAddress; |
|
|
|
import java.net.URL; |
|
|
|
import java.net.URL; |
|
|
|
|
|
|
|
|
|
|
|
import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; |
|
|
|
import org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory; |
|
|
|
@ -50,7 +51,7 @@ import org.springframework.util.ResourceUtils; |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class SslServerCustomizer implements JettyServerCustomizer { |
|
|
|
class SslServerCustomizer implements JettyServerCustomizer { |
|
|
|
|
|
|
|
|
|
|
|
private final int port; |
|
|
|
private final InetSocketAddress address; |
|
|
|
|
|
|
|
|
|
|
|
private final Ssl ssl; |
|
|
|
private final Ssl ssl; |
|
|
|
|
|
|
|
|
|
|
|
@ -58,9 +59,9 @@ class SslServerCustomizer implements JettyServerCustomizer { |
|
|
|
|
|
|
|
|
|
|
|
private final Http2 http2; |
|
|
|
private final Http2 http2; |
|
|
|
|
|
|
|
|
|
|
|
SslServerCustomizer(int port, Ssl ssl, SslStoreProvider sslStoreProvider, |
|
|
|
SslServerCustomizer(InetSocketAddress address, Ssl ssl, |
|
|
|
Http2 http2) { |
|
|
|
SslStoreProvider sslStoreProvider, Http2 http2) { |
|
|
|
this.port = port; |
|
|
|
this.address = address; |
|
|
|
this.ssl = ssl; |
|
|
|
this.ssl = ssl; |
|
|
|
this.sslStoreProvider = sslStoreProvider; |
|
|
|
this.sslStoreProvider = sslStoreProvider; |
|
|
|
this.http2 = http2; |
|
|
|
this.http2 = http2; |
|
|
|
@ -70,20 +71,22 @@ class SslServerCustomizer implements JettyServerCustomizer { |
|
|
|
public void customize(Server server) { |
|
|
|
public void customize(Server server) { |
|
|
|
SslContextFactory sslContextFactory = new SslContextFactory(); |
|
|
|
SslContextFactory sslContextFactory = new SslContextFactory(); |
|
|
|
configureSsl(sslContextFactory, this.ssl, this.sslStoreProvider); |
|
|
|
configureSsl(sslContextFactory, this.ssl, this.sslStoreProvider); |
|
|
|
ServerConnector connector = createConnector(server, sslContextFactory, this.port); |
|
|
|
ServerConnector connector = createConnector(server, sslContextFactory, |
|
|
|
|
|
|
|
this.address); |
|
|
|
server.setConnectors(new Connector[] { connector }); |
|
|
|
server.setConnectors(new Connector[] { connector }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private ServerConnector createConnector(Server server, |
|
|
|
private ServerConnector createConnector(Server server, |
|
|
|
SslContextFactory sslContextFactory, int port) { |
|
|
|
SslContextFactory sslContextFactory, InetSocketAddress address) { |
|
|
|
HttpConfiguration config = new HttpConfiguration(); |
|
|
|
HttpConfiguration config = new HttpConfiguration(); |
|
|
|
config.setSendServerVersion(false); |
|
|
|
config.setSendServerVersion(false); |
|
|
|
config.setSecureScheme("https"); |
|
|
|
config.setSecureScheme("https"); |
|
|
|
config.setSecurePort(port); |
|
|
|
config.setSecurePort(address.getPort()); |
|
|
|
config.addCustomizer(new SecureRequestCustomizer()); |
|
|
|
config.addCustomizer(new SecureRequestCustomizer()); |
|
|
|
ServerConnector connector = createServerConnector(server, sslContextFactory, |
|
|
|
ServerConnector connector = createServerConnector(server, sslContextFactory, |
|
|
|
config); |
|
|
|
config); |
|
|
|
connector.setPort(port); |
|
|
|
connector.setPort(address.getPort()); |
|
|
|
|
|
|
|
connector.setHost(address.getHostString()); |
|
|
|
return connector; |
|
|
|
return connector; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|