public T build() throws SSLException {
        final SslContext sslContext;
        {
            final SslProvider sslProvider;

            if (OpenSsl.isAvailable()) {
                log.info("Native SSL provider is available; will use native provider.");
                sslProvider = SslProvider.OPENSSL;
            } else {
                log.info("Native SSL provider not available; will use JDK SSL provider.");
                sslProvider = SslProvider.JDK;
            }

            final SslContextBuilder sslContextBuilder;

            if (this.certificateChain != null && this.privateKey != null) {
                sslContextBuilder = SslContextBuilder.forServer(this.privateKey, this.privateKeyPassword, this.certificateChain);
            } else if (this.certificateChainPemFile != null && this.privateKeyPkcs8File != null) {
                sslContextBuilder = SslContextBuilder.forServer(this.certificateChainPemFile, this.privateKeyPkcs8File, this.privateKeyPassword);
            } else if (this.certificateChainInputStream != null && this.privateKeyPkcs8InputStream != null) {
                sslContextBuilder = SslContextBuilder.forServer(this.certificateChainInputStream, this.privateKeyPkcs8InputStream, this.privateKeyPassword);
            } else {
                throw new IllegalStateException("Must specify server credentials before building a mock server.");
            }

            sslContextBuilder.sslProvider(sslProvider)
                    .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
                    .clientAuth(ClientAuth.OPTIONAL);

            if (this.trustedClientCertificatePemFile != null) {
                sslContextBuilder.trustManager(this.trustedClientCertificatePemFile);
            } else if (this.trustedClientCertificateInputStream != null) {
                sslContextBuilder.trustManager(this.trustedClientCertificateInputStream);
            } else if (this.trustedClientCertificates != null) {
                sslContextBuilder.trustManager(this.trustedClientCertificates);
            }

            if (this.useAlpn) {
                sslContextBuilder.applicationProtocolConfig(new ApplicationProtocolConfig(
                        ApplicationProtocolConfig.Protocol.ALPN,
                        ApplicationProtocolConfig.SelectorFailureBehavior.NO_ADVERTISE,
                        ApplicationProtocolConfig.SelectedListenerFailureBehavior.ACCEPT,
                        ApplicationProtocolNames.HTTP_2));
            }

            sslContext = sslContextBuilder.build();
        }

        final T server = this.constructServer(sslContext);

        if (sslContext instanceof ReferenceCounted) {
            ((ReferenceCounted) sslContext).release();
        }

        return server;
    }
public T build ( ) throws SSLException { final SslContext sslContext ; { final SslProvider sslProvider ; if ( OpenSsl . isAvailable ( ) ) { log . info ( "Native SSL provider is available; will use native provider." ) ; sslProvider = SslProvider . OPENSSL ; } else { log . info ( "Native SSL provider not available; will use JDK SSL provider." ) ; sslProvider = SslProvider . JDK ; } final SslContextBuilder sslContextBuilder ; if ( this . certificateChain != null && this . privateKey != null ) { sslContextBuilder = SslContextBuilder . forServer ( this . privateKey , this . privateKeyPassword , this . certificateChain ) ; } else if ( this . certificateChainPemFile != null && this . privateKeyPkcs8File != null ) { sslContextBuilder = SslContextBuilder . forServer ( this . certificateChainPemFile , this . privateKeyPkcs8File , this . privateKeyPassword ) ; } else if ( this . certificateChainInputStream != null && this . privateKeyPkcs8InputStream != null ) { sslContextBuilder = SslContextBuilder . forServer ( this . certificateChainInputStream , this . privateKeyPkcs8InputStream , this . privateKeyPassword ) ; } else { throw new IllegalStateException ( "Must specify server credentials before building a mock server." ) ; } sslContextBuilder . sslProvider ( sslProvider ) . ciphers ( Http2SecurityUtil . CIPHERS , SupportedCipherSuiteFilter . INSTANCE ) . clientAuth ( ClientAuth . OPTIONAL ) ; if ( this . trustedClientCertificatePemFile != null ) { sslContextBuilder . trustManager ( this . trustedClientCertificatePemFile ) ; } else if ( this . trustedClientCertificateInputStream != null ) { sslContextBuilder . trustManager ( this . trustedClientCertificateInputStream ) ; } else if ( this . trustedClientCertificates != null ) { sslContextBuilder . trustManager ( this . trustedClientCertificates ) ; } if ( this . useAlpn ) { sslContextBuilder . applicationProtocolConfig ( new ApplicationProtocolConfig ( ApplicationProtocolConfig . Protocol . ALPN , ApplicationProtocolConfig . SelectorFailureBehavior . NO_ADVERTISE , ApplicationProtocolConfig . SelectedListenerFailureBehavior . ACCEPT , ApplicationProtocolNames . HTTP_2 ) ) ; } sslContext = sslContextBuilder . build ( ) ; } final T server = this . constructServer ( sslContext ) ; if ( sslContext instanceof ReferenceCounted ) { ( ( ReferenceCounted ) sslContext ) . release ( ) ; } return server ; }
Constructs a new server with the previously-set configuration.

@return a new server instance with the previously-set configuration

@throws SSLException if an SSL context could not be created for the new server for any reason

@since 0.8