Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
a1dda12b
Commit
a1dda12b
authored
Nov 11, 2016
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Disable Server header by default when using SSL with Jetty 9
Closes gh-7359
parent
72e696bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
0 deletions
+36
-0
JettyEmbeddedServletContainerFactory.java
.../embedded/jetty/JettyEmbeddedServletContainerFactory.java
+1
-0
AbstractEmbeddedServletContainerFactoryTests.java
...mbedded/AbstractEmbeddedServletContainerFactoryTests.java
+35
-0
No files found.
spring-boot/src/main/java/org/springframework/boot/context/embedded/jetty/JettyEmbeddedServletContainerFactory.java
View file @
a1dda12b
...
@@ -692,6 +692,7 @@ public class JettyEmbeddedServletContainerFactory
...
@@ -692,6 +692,7 @@ public class JettyEmbeddedServletContainerFactory
public
ServerConnector
getConnector
(
Server
server
,
public
ServerConnector
getConnector
(
Server
server
,
SslContextFactory
sslContextFactory
,
int
port
)
{
SslContextFactory
sslContextFactory
,
int
port
)
{
HttpConfiguration
config
=
new
HttpConfiguration
();
HttpConfiguration
config
=
new
HttpConfiguration
();
config
.
setSendServerVersion
(
false
);
config
.
addCustomizer
(
new
SecureRequestCustomizer
());
config
.
addCustomizer
(
new
SecureRequestCustomizer
());
HttpConnectionFactory
connectionFactory
=
new
HttpConnectionFactory
(
config
);
HttpConnectionFactory
connectionFactory
=
new
HttpConnectionFactory
(
config
);
SslConnectionFactory
sslConnectionFactory
=
new
SslConnectionFactory
(
SslConnectionFactory
sslConnectionFactory
=
new
SslConnectionFactory
(
...
...
spring-boot/src/test/java/org/springframework/boot/context/embedded/AbstractEmbeddedServletContainerFactoryTests.java
View file @
a1dda12b
...
@@ -420,6 +420,41 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
...
@@ -420,6 +420,41 @@ public abstract class AbstractEmbeddedServletContainerFactoryTests {
.
contains
(
"scheme=https"
);
.
contains
(
"scheme=https"
);
}
}
@Test
public
void
serverHeaderIsDisabledByDefaultWhenUsingSsl
()
throws
Exception
{
AbstractEmbeddedServletContainerFactory
factory
=
getFactory
();
factory
.
setSsl
(
getSsl
(
null
,
"password"
,
"src/test/resources/test.jks"
));
this
.
container
=
factory
.
getEmbeddedServletContainer
(
new
ServletRegistrationBean
(
new
ExampleServlet
(
true
,
false
),
"/hello"
));
this
.
container
.
start
();
SSLConnectionSocketFactory
socketFactory
=
new
SSLConnectionSocketFactory
(
new
SSLContextBuilder
()
.
loadTrustMaterial
(
null
,
new
TrustSelfSignedStrategy
()).
build
());
HttpClient
httpClient
=
HttpClients
.
custom
().
setSSLSocketFactory
(
socketFactory
)
.
build
();
ClientHttpResponse
response
=
getClientResponse
(
getLocalUrl
(
"https"
,
"/hello"
),
HttpMethod
.
GET
,
new
HttpComponentsClientHttpRequestFactory
(
httpClient
));
assertThat
(
response
.
getHeaders
().
get
(
"Server"
)).
isNullOrEmpty
();
}
@Test
public
void
serverHeaderCanBeCustomizedWhenUsingSsl
()
throws
Exception
{
AbstractEmbeddedServletContainerFactory
factory
=
getFactory
();
factory
.
setServerHeader
(
"MyServer"
);
factory
.
setSsl
(
getSsl
(
null
,
"password"
,
"src/test/resources/test.jks"
));
this
.
container
=
factory
.
getEmbeddedServletContainer
(
new
ServletRegistrationBean
(
new
ExampleServlet
(
true
,
false
),
"/hello"
));
this
.
container
.
start
();
SSLConnectionSocketFactory
socketFactory
=
new
SSLConnectionSocketFactory
(
new
SSLContextBuilder
()
.
loadTrustMaterial
(
null
,
new
TrustSelfSignedStrategy
()).
build
());
HttpClient
httpClient
=
HttpClients
.
custom
().
setSSLSocketFactory
(
socketFactory
)
.
build
();
ClientHttpResponse
response
=
getClientResponse
(
getLocalUrl
(
"https"
,
"/hello"
),
HttpMethod
.
GET
,
new
HttpComponentsClientHttpRequestFactory
(
httpClient
));
assertThat
(
response
.
getHeaders
().
get
(
"Server"
)).
containsExactly
(
"MyServer"
);
}
protected
final
void
testBasicSslWithKeyStore
(
String
keyStore
)
throws
Exception
{
protected
final
void
testBasicSslWithKeyStore
(
String
keyStore
)
throws
Exception
{
AbstractEmbeddedServletContainerFactory
factory
=
getFactory
();
AbstractEmbeddedServletContainerFactory
factory
=
getFactory
();
addTestTxtFile
(
factory
);
addTestTxtFile
(
factory
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment