Support configuration of web SSL using PEM-encoded certificates · spring-projects/spring-boot@d387b3f (original) (raw)

1

1

`/*

`

2

``

`-

`

``

2

`+

`

3

3

` *

`

4

4

` * Licensed under the Apache License, Version 2.0 (the "License");

`

5

5

` * you may not use this file except in compliance with the License.

`

39

39

`import org.springframework.boot.rsocket.server.RSocketServer;

`

40

40

`import org.springframework.boot.rsocket.server.RSocketServerCustomizer;

`

41

41

`import org.springframework.boot.rsocket.server.RSocketServerFactory;

`

``

42

`+

import org.springframework.boot.web.server.CertificateFileSslStoreProvider;

`

42

43

`import org.springframework.boot.web.server.Ssl;

`

43

44

`import org.springframework.boot.web.server.SslStoreProvider;

`

44

45

`import org.springframework.http.client.reactive.ReactorResourceFactory;

`

`@@ -51,6 +52,7 @@

`

51

52

` *

`

52

53

` * @author Brian Clozel

`

53

54

` * @author Chris Bono

`

``

55

`+

`

54

56

` * @since 2.2.0

`

55

57

` */

`

56

58

`public class NettyRSocketServerFactory implements RSocketServerFactory, ConfigurableRSocketServerFactory {

`

`@@ -179,7 +181,7 @@ private ServerTransport createWebSocketTransport() {

`

179

181

`@SuppressWarnings("deprecation")

`

180

182

`private HttpServer customizeSslConfiguration(HttpServer httpServer) {

`

181

183

`org.springframework.boot.web.embedded.netty.SslServerCustomizer sslServerCustomizer = new org.springframework.boot.web.embedded.netty.SslServerCustomizer(

`

182

``

`-

this.ssl, null, this.sslStoreProvider);

`

``

184

`+

this.ssl, null, getOrCreateSslStoreProvider());

`

183

185

`return sslServerCustomizer.apply(httpServer);

`

184

186

` }

`

185

187

``

`@@ -189,12 +191,20 @@ private ServerTransport createTcpTransport() {

`

189

191

`tcpServer = tcpServer.runOn(this.resourceFactory.getLoopResources());

`

190

192

` }

`

191

193

`if (this.ssl != null && this.ssl.isEnabled()) {

`

192

``

`-

TcpSslServerCustomizer sslServerCustomizer = new TcpSslServerCustomizer(this.ssl, this.sslStoreProvider);

`

``

194

`+

TcpSslServerCustomizer sslServerCustomizer = new TcpSslServerCustomizer(this.ssl,

`

``

195

`+

getOrCreateSslStoreProvider());

`

193

196

`tcpServer = sslServerCustomizer.apply(tcpServer);

`

194

197

` }

`

195

198

`return TcpServerTransport.create(tcpServer.bindAddress(this::getListenAddress));

`

196

199

` }

`

197

200

``

``

201

`+

private SslStoreProvider getOrCreateSslStoreProvider() {

`

``

202

`+

if (this.sslStoreProvider != null) {

`

``

203

`+

return this.sslStoreProvider;

`

``

204

`+

}

`

``

205

`+

return CertificateFileSslStoreProvider.from(this.ssl);

`

``

206

`+

}

`

``

207

+

198

208

`private InetSocketAddress getListenAddress() {

`

199

209

`if (this.address != null) {

`

200

210

`return new InetSocketAddress(this.address.getHostAddress(), this.port);

`