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
b78c7aca
Commit
b78c7aca
authored
Oct 13, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow ALPNServerConnectionFactory to negotiate use of HTTP/1.1
Closes gh-14444
parent
a86ba649
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
98 additions
and
1 deletion
+98
-1
SslServerCustomizer.java
...ramework/boot/web/embedded/jetty/SslServerCustomizer.java
+0
-1
SslServerCustomizerTests.java
...ork/boot/web/embedded/jetty/SslServerCustomizerTests.java
+98
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/jetty/SslServerCustomizer.java
View file @
b78c7aca
...
...
@@ -124,7 +124,6 @@ class SslServerCustomizer implements JettyServerCustomizer {
HttpConfiguration
config
,
SslContextFactory
sslContextFactory
)
{
HTTP2ServerConnectionFactory
h2
=
new
HTTP2ServerConnectionFactory
(
config
);
ALPNServerConnectionFactory
alpn
=
new
ALPNServerConnectionFactory
();
alpn
.
setDefaultProtocol
(
"h2"
);
sslContextFactory
.
setCipherComparator
(
HTTP2Cipher
.
COMPARATOR
);
sslContextFactory
.
setProvider
(
"Conscrypt"
);
SslConnectionFactory
ssl
=
new
SslConnectionFactory
(
sslContextFactory
,
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/jetty/SslServerCustomizerTests.java
0 → 100644
View file @
b78c7aca
/*
* Copyright 2012-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org
.
springframework
.
boot
.
web
.
embedded
.
jetty
;
import
java.net.InetSocketAddress
;
import
java.util.ArrayList
;
import
java.util.List
;
import
org.eclipse.jetty.alpn.server.ALPNServerConnectionFactory
;
import
org.eclipse.jetty.http2.server.HTTP2ServerConnectionFactory
;
import
org.eclipse.jetty.server.ConnectionFactory
;
import
org.eclipse.jetty.server.HttpConnectionFactory
;
import
org.eclipse.jetty.server.Server
;
import
org.eclipse.jetty.server.SslConnectionFactory
;
import
org.junit.Test
;
import
org.springframework.boot.web.server.Http2
;
import
org.springframework.boot.web.server.Ssl
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
/**
* Tests for {@link SslServerCustomizer}.
*
* @author Andy Wilkinson
*/
public
class
SslServerCustomizerTests
{
@Test
@SuppressWarnings
(
"rawtypes"
)
public
void
whenHttp2IsNotEnabledServerConnectorHasSslAndHttpConnectionFactories
()
{
Server
server
=
createCustomizedServer
();
assertThat
(
server
.
getConnectors
()).
hasSize
(
1
);
List
<
ConnectionFactory
>
factories
=
new
ArrayList
<>(
server
.
getConnectors
()[
0
].
getConnectionFactories
());
assertThat
(
factories
).
extracting
((
factory
)
->
(
Class
)
factory
.
getClass
())
.
containsExactly
(
SslConnectionFactory
.
class
,
HttpConnectionFactory
.
class
);
}
@Test
@SuppressWarnings
(
"rawtypes"
)
public
void
whenHttp2IsEnabledServerConnectorsHasSslAlpnH2AndHttpConnectionFactories
()
{
Http2
http2
=
new
Http2
();
http2
.
setEnabled
(
true
);
Server
server
=
createCustomizedServer
(
http2
);
assertThat
(
server
.
getConnectors
()).
hasSize
(
1
);
List
<
ConnectionFactory
>
factories
=
new
ArrayList
<>(
server
.
getConnectors
()[
0
].
getConnectionFactories
());
assertThat
(
factories
).
extracting
((
factory
)
->
(
Class
)
factory
.
getClass
())
.
containsExactly
(
SslConnectionFactory
.
class
,
ALPNServerConnectionFactory
.
class
,
HTTP2ServerConnectionFactory
.
class
,
HttpConnectionFactory
.
class
);
}
@Test
public
void
alpnConnectionFactoryHasNullDefaultProtocolToAllowNegotiationToHttp11
()
{
Http2
http2
=
new
Http2
();
http2
.
setEnabled
(
true
);
Server
server
=
createCustomizedServer
(
http2
);
assertThat
(
server
.
getConnectors
()).
hasSize
(
1
);
List
<
ConnectionFactory
>
factories
=
new
ArrayList
<>(
server
.
getConnectors
()[
0
].
getConnectionFactories
());
assertThat
(((
ALPNServerConnectionFactory
)
factories
.
get
(
1
)).
getDefaultProtocol
())
.
isNull
();
}
private
Server
createCustomizedServer
()
{
return
createCustomizedServer
(
new
Http2
());
}
private
Server
createCustomizedServer
(
Http2
http2
)
{
Ssl
ssl
=
new
Ssl
();
ssl
.
setKeyStore
(
"classpath:test.jks"
);
return
createCustomizedServer
(
ssl
,
http2
);
}
private
Server
createCustomizedServer
(
Ssl
ssl
,
Http2
http2
)
{
Server
server
=
new
Server
();
new
SslServerCustomizer
(
new
InetSocketAddress
(
0
),
ssl
,
null
,
http2
)
.
customize
(
server
);
return
server
;
}
}
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