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
1afdfef8
Commit
1afdfef8
authored
Oct 08, 2018
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '2.0.x'
parents
7da33965
d6d59edb
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
8 deletions
+49
-8
SslBuilderCustomizer.java
...work/boot/web/embedded/undertow/SslBuilderCustomizer.java
+8
-7
SslBuilderCustomizerTests.java
...boot/web/embedded/undertow/SslBuilderCustomizerTests.java
+41
-1
No files found.
spring-boot-project/spring-boot/src/main/java/org/springframework/boot/web/embedded/undertow/SslBuilderCustomizer.java
View file @
1afdfef8
...
@@ -144,8 +144,8 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer {
...
@@ -144,8 +144,8 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer {
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
());
}
}
private
TrustManager
[]
getTrustManagers
(
Ssl
ssl
,
SslStoreProvider
sslStoreProvider
)
{
private
TrustManager
[]
getTrustManagers
(
Ssl
ssl
,
SslStoreProvider
sslStoreProvider
)
{
...
@@ -166,17 +166,18 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer {
...
@@ -166,17 +166,18 @@ class SslBuilderCustomizer implements UndertowBuilderCustomizer {
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/undertow/SslBuilderCustomizerTests.java
View file @
1afdfef8
/*
/*
* Copyright 2012-201
7
the original author or authors.
* Copyright 2012-201
8
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
package
org
.
springframework
.
boot
.
web
.
embedded
.
undertow
;
package
org
.
springframework
.
boot
.
web
.
embedded
.
undertow
;
import
java.net.InetAddress
;
import
java.net.InetAddress
;
import
java.security.NoSuchProviderException
;
import
javax.net.ssl.KeyManager
;
import
javax.net.ssl.KeyManager
;
...
@@ -26,6 +27,7 @@ import org.springframework.boot.web.server.Ssl;
...
@@ -26,6 +27,7 @@ import org.springframework.boot.web.server.Ssl;
import
org.springframework.test.util.ReflectionTestUtils
;
import
org.springframework.test.util.ReflectionTestUtils
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
junit
.
Assert
.
fail
;
/**
/**
* Tests for {@link SslBuilderCustomizer}
* Tests for {@link SslBuilderCustomizer}
...
@@ -48,4 +50,42 @@ public class SslBuilderCustomizerTests {
...
@@ -48,4 +50,42 @@ public class SslBuilderCustomizerTests {
assertThat
(
keyManagers
[
0
]).
isNotInstanceOf
(
name
);
assertThat
(
keyManagers
[
0
]).
isNotInstanceOf
(
name
);
}
}
@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"
);
SslBuilderCustomizer
customizer
=
new
SslBuilderCustomizer
(
8080
,
InetAddress
.
getLocalHost
(),
ssl
,
null
);
try
{
ReflectionTestUtils
.
invokeMethod
(
customizer
,
"getKeyManagers"
,
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"
);
SslBuilderCustomizer
customizer
=
new
SslBuilderCustomizer
(
8080
,
InetAddress
.
getLocalHost
(),
ssl
,
null
);
try
{
ReflectionTestUtils
.
invokeMethod
(
customizer
,
"getTrustManagers"
,
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