16
16
17
17
package org .springframework .http .server .reactive .bootstrap ;
18
18
19
- import java .security .cert .CertificateException ;
20
19
import java .util .concurrent .atomic .AtomicReference ;
21
20
22
- import reactor .core .Exceptions ;
21
+ import io .netty .handler .ssl .SslContextBuilder ;
22
+ import io .netty .handler .ssl .util .SelfSignedCertificate ;
23
23
import reactor .netty .DisposableServer ;
24
24
import reactor .netty .tcp .SslProvider .DefaultConfigurationType ;
25
25
26
26
import org .springframework .http .server .reactive .ReactorHttpHandlerAdapter ;
27
27
28
- import io .netty .handler .ssl .SslContextBuilder ;
29
- import io .netty .handler .ssl .util .SelfSignedCertificate ;
30
-
31
28
/**
32
29
* @author Stephane Maldini
33
30
*/
@@ -41,22 +38,16 @@ public class ReactorHttpsServer extends AbstractHttpServer {
41
38
42
39
43
40
@ Override
44
- protected void initServer () {
41
+ protected void initServer () throws Exception {
42
+
43
+ SelfSignedCertificate cert = new SelfSignedCertificate ();
44
+ SslContextBuilder builder = SslContextBuilder .forServer (cert .certificate (), cert .privateKey ());
45
+
45
46
this .reactorHandler = createHttpHandlerAdapter ();
46
- SelfSignedCertificate cert = null ;
47
- try {
48
- cert = new SelfSignedCertificate ();
49
- }
50
- catch (CertificateException e ) {
51
- throw Exceptions .propagate (e );
52
- }
53
- SslContextBuilder sslContextBuilder =
54
- SslContextBuilder .forServer (cert .certificate (), cert .privateKey ());
55
47
this .reactorServer = reactor .netty .http .server .HttpServer .create ()
56
48
.host (getHost ())
57
49
.port (getPort ())
58
- .secure (sslContextSpec -> sslContextSpec .sslContext (sslContextBuilder )
59
- .defaultConfiguration (DefaultConfigurationType .TCP ));
50
+ .secure (spec -> spec .sslContext (builder ).defaultConfiguration (DefaultConfigurationType .TCP ));
60
51
}
61
52
62
53
private ReactorHttpHandlerAdapter createHttpHandlerAdapter () {
0 commit comments