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
1e0f2b65
Commit
1e0f2b65
authored
Oct 08, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
1afdfef8
5d3f30ee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
7 deletions
+79
-7
SslServerCustomizer.java
...ramework/boot/web/embedded/netty/SslServerCustomizer.java
+8
-7
SslServerCustomizerTests.java
...ork/boot/web/embedded/netty/SslServerCustomizerTests.java
+71
-0
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/netty/SslServerCustomizer.java
View file @
1e0f2b65
...
@@ -112,8 +112,8 @@ public class SslServerCustomizer implements NettyServerCustomizer {
...
@@ -112,8 +112,8 @@ public class SslServerCustomizer implements NettyServerCustomizer {
if
(
sslStoreProvider
!=
null
)
{
if
(
sslStoreProvider
!=
null
)
{
return
sslStoreProvider
.
getKeyStore
();
return
sslStoreProvider
.
getKeyStore
();
}
}
return
loadKeyStore
(
ssl
.
getKeyStoreType
(),
ssl
.
getKeyStore
(),
return
loadKeyStore
(
ssl
.
getKeyStoreType
(),
ssl
.
getKeyStore
Provider
(),
ssl
.
getKeyStorePassword
());
ssl
.
getKeyStore
(),
ssl
.
getKeyStore
Password
());
}
}
protected
TrustManagerFactory
getTrustManagerFactory
(
Ssl
ssl
,
protected
TrustManagerFactory
getTrustManagerFactory
(
Ssl
ssl
,
...
@@ -135,17 +135,18 @@ public class SslServerCustomizer implements NettyServerCustomizer {
...
@@ -135,17 +135,18 @@ public class SslServerCustomizer implements NettyServerCustomizer {
if
(
sslStoreProvider
!=
null
)
{
if
(
sslStoreProvider
!=
null
)
{
return
sslStoreProvider
.
getTrustStore
();
return
sslStoreProvider
.
getTrustStore
();
}
}
return
loadKeyStore
(
ssl
.
getTrustStoreType
(),
ssl
.
getTrustStore
(),
return
loadKeyStore
(
ssl
.
getTrustStoreType
(),
ssl
.
getTrustStore
Provider
(),
ssl
.
getTrustStorePassword
());
ssl
.
getTrustStore
(),
ssl
.
getTrustStore
Password
());
}
}
private
KeyStore
loadKeyStore
(
String
type
,
String
resource
,
String
password
)
private
KeyStore
loadKeyStore
(
String
type
,
String
provider
,
String
resource
,
throws
Exception
{
String
password
)
throws
Exception
{
type
=
(
type
!=
null
)
?
type
:
"JKS"
;
type
=
(
type
!=
null
)
?
type
:
"JKS"
;
if
(
resource
==
null
)
{
if
(
resource
==
null
)
{
return
null
;
return
null
;
}
}
KeyStore
store
=
KeyStore
.
getInstance
(
type
);
KeyStore
store
=
(
provider
!=
null
)
?
KeyStore
.
getInstance
(
type
,
provider
)
:
KeyStore
.
getInstance
(
type
);
URL
url
=
ResourceUtils
.
getURL
(
resource
);
URL
url
=
ResourceUtils
.
getURL
(
resource
);
store
.
load
(
url
.
openStream
(),
(
password
!=
null
)
?
password
.
toCharArray
()
:
null
);
store
.
load
(
url
.
openStream
(),
(
password
!=
null
)
?
password
.
toCharArray
()
:
null
);
return
store
;
return
store
;
...
...
spring-boot-project/spring-boot/src/test/java/org/springframework/boot/web/embedded/netty/SslServerCustomizerTests.java
0 → 100644
View file @
1e0f2b65
/*
* 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
.
netty
;
import
java.security.NoSuchProviderException
;
import
org.junit.Test
;
import
org.springframework.boot.web.server.Ssl
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
junit
.
Assert
.
fail
;
/**
* Tests for {@link SslServerCustomizer}.
*
* @author Andy Wilkinson
*/
public
class
SslServerCustomizerTests
{
@Test
public
void
keyStoreProviderIsUsedWhenCreatingKeyStore
()
throws
Exception
{
Ssl
ssl
=
new
Ssl
();
ssl
.
setKeyPassword
(
"password"
);
ssl
.
setKeyStore
(
"src/test/resources/test.jks"
);
ssl
.
setKeyStoreProvider
(
"com.example.KeyStoreProvider"
);
SslServerCustomizer
customizer
=
new
SslServerCustomizer
(
ssl
,
null
);
try
{
customizer
.
getKeyManagerFactory
(
ssl
,
null
);
fail
();
}
catch
(
IllegalStateException
ex
)
{
Throwable
cause
=
ex
.
getCause
();
assertThat
(
cause
).
isInstanceOf
(
NoSuchProviderException
.
class
);
assertThat
(
cause
).
hasMessageContaining
(
"com.example.KeyStoreProvider"
);
}
}
@Test
public
void
trustStoreProviderIsUsedWhenCreatingTrustStore
()
throws
Exception
{
Ssl
ssl
=
new
Ssl
();
ssl
.
setTrustStorePassword
(
"password"
);
ssl
.
setTrustStore
(
"src/test/resources/test.jks"
);
ssl
.
setTrustStoreProvider
(
"com.example.TrustStoreProvider"
);
SslServerCustomizer
customizer
=
new
SslServerCustomizer
(
ssl
,
null
);
try
{
customizer
.
getTrustManagerFactory
(
ssl
,
null
);
fail
();
}
catch
(
IllegalStateException
ex
)
{
Throwable
cause
=
ex
.
getCause
();
assertThat
(
cause
).
isInstanceOf
(
NoSuchProviderException
.
class
);
assertThat
(
cause
).
hasMessageContaining
(
"com.example.TrustStoreProvider"
);
}
}
}
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