@ -38,9 +38,10 @@ import javax.net.ssl.TrustManagerFactory;
import javax.net.ssl.X509ExtendedKeyManager ;
import io.netty.handler.ssl.ClientAuth ;
import io.netty.handler.ssl.SslContextBuilder ;
import reactor.netty.http.Http11SslContextSpec ;
import reactor.netty.http.Http2SslContextSpec ;
import reactor.netty.http.server.HttpServer ;
import reactor.netty.tcp. SslProvider ;
import reactor.netty.tcp. AbstractProtocolSslContextSpec ;
import org.springframework.boot.web.server.Http2 ;
import org.springframework.boot.web.server.Ssl ;
@ -57,7 +58,9 @@ import org.springframework.util.ResourceUtils;
* @author Raheela Aslam
* @author Chris Bono
* @since 2.0 .0
* @deprecated this class is meant for Spring Boot internal use only .
* /
@Deprecated
public class SslServerCustomizer implements NettyServerCustomizer {
private final Ssl ssl ;
@ -74,38 +77,37 @@ public class SslServerCustomizer implements NettyServerCustomizer {
@Override
public HttpServer apply ( HttpServer server ) {
try {
return server . secure ( ( contextSpec ) - > {
SslProvider . DefaultConfigurationSpec spec = contextSpec . sslContext ( getContextBuilder ( ) ) ;
if ( this . http2 ! = null & & this . http2 . isEnabled ( ) ) {
spec . defaultConfiguration ( SslProvider . DefaultConfigurationType . H2 ) ;
}
} ) ;
}
catch ( Exception ex ) {
throw new IllegalStateException ( ex ) ;
}
AbstractProtocolSslContextSpec < ? > sslContextSpec = createSslContextSpec ( ) ;
return server . secure ( ( spec ) - > spec . sslContext ( sslContextSpec ) ) ;
}
protected SslContextBuilder getContextBuilder ( ) {
SslContextBuilder builder = SslContextBuilder . forServer ( getKeyManagerFactory ( this . ssl , this . sslStoreProvider ) )
. trustManager ( getTrustManagerFactory ( this . ssl , this . sslStoreProvider ) ) ;
if ( this . ssl . getEnabledProtocols ( ) ! = null ) {
builder . protocols ( this . ssl . getEnabledProtocols ( ) ) ;
}
if ( this . ssl . getCiphers ( ) ! = null ) {
builder . ciphers ( Arrays . asList ( this . ssl . getCiphers ( ) ) ) ;
protected AbstractProtocolSslContextSpec < ? > createSslContextSpec ( ) {
AbstractProtocolSslContextSpec < ? > sslContextSpec ;
if ( this . http2 ! = null & & this . http2 . isEnabled ( ) ) {
sslContextSpec = Http2SslContextSpec . forServer ( getKeyManagerFactory ( this . ssl , this . sslStoreProvider ) ) ;
}
if ( this . ssl . g etC lientAuth( ) = = S sl. Cli entAuth. NEED ) {
builder. clientAuth ( ClientAuth . REQUIRE ) ;
else {
sslContextSpec = Http11SslContextSpec . forServer ( getKeyManagerFactory ( this . ssl , this . sslStoreProvider ) ) ;
}
else if ( this . ssl . getClientAuth ( ) = = Ssl . ClientAuth . WANT ) {
builder . clientAuth ( ClientAuth . OPTIONAL ) ;
}
return builder ;
sslContextSpec . configure ( ( builder ) - > {
builder . trustManager ( getTrustManagerFactory ( this . ssl , this . sslStoreProvider ) ) ;
if ( this . ssl . getEnabledProtocols ( ) ! = null ) {
builder . protocols ( this . ssl . getEnabledProtocols ( ) ) ;
}
if ( this . ssl . getCiphers ( ) ! = null ) {
builder . ciphers ( Arrays . asList ( this . ssl . getCiphers ( ) ) ) ;
}
if ( this . ssl . getClientAuth ( ) = = Ssl . ClientAuth . NEED ) {
builder . clientAuth ( ClientAuth . REQUIRE ) ;
}
else if ( this . ssl . getClientAuth ( ) = = Ssl . ClientAuth . WANT ) {
builder . clientAuth ( ClientAuth . OPTIONAL ) ;
}
} ) ;
return sslContextSpec ;
}
protected KeyManagerFactory getKeyManagerFactory ( Ssl ssl , SslStoreProvider sslStoreProvider ) {
KeyManagerFactory getKeyManagerFactory ( Ssl ssl , SslStoreProvider sslStoreProvider ) {
try {
KeyStore keyStore = getKeyStore ( ssl , sslStoreProvider ) ;
SslConfigurationValidator . validateKeyAlias ( keyStore , ssl . getKeyAlias ( ) ) ;
@ -133,7 +135,7 @@ public class SslServerCustomizer implements NettyServerCustomizer {
ssl . getKeyStorePassword ( ) ) ;
}
protected TrustManagerFactory getTrustManagerFactory ( Ssl ssl , SslStoreProvider sslStoreProvider ) {
TrustManagerFactory getTrustManagerFactory ( Ssl ssl , SslStoreProvider sslStoreProvider ) {
try {
KeyStore store = getTrustStore ( ssl , sslStoreProvider ) ;
TrustManagerFactory trustManagerFactory = TrustManagerFactory