|
20 | 20 | import java.util.List;
|
21 | 21 | import java.util.Map;
|
22 | 22 | import java.util.Set;
|
| 23 | +import java.util.function.BiFunction; |
23 | 24 | import java.util.function.Function;
|
| 25 | +import java.util.function.Predicate; |
24 | 26 | import java.util.function.Supplier;
|
25 | 27 | import java.util.stream.Collectors;
|
26 | 28 |
|
| 29 | +import org.springframework.boot.ssl.pem.PemCertificate; |
27 | 30 | import org.springframework.boot.ssl.SslBundle;
|
28 | 31 | import org.springframework.boot.ssl.SslBundleRegistry;
|
29 | 32 |
|
@@ -90,21 +93,33 @@ private Set<WatchablePath> watchedJksPaths(Bundle<JksSslBundleProperties> bundle
|
90 | 93 |
|
91 | 94 | private Set<WatchablePath> watchedPemPaths(Bundle<PemSslBundleProperties> bundle) {
|
92 | 95 | List<BundleContentProperty> watched = new ArrayList<>();
|
| 96 | + BiFunction<String, String, BundleContentProperty> contentKeyStoreCertificateProperty = locationToBundleContentProperty(); |
93 | 97 | watched
|
94 | 98 | .add(new BundleContentProperty("keystore.private-key", bundle.properties().getKeystore().getPrivateKey()));
|
95 |
| - watched |
96 |
| - .add(new BundleContentProperty("keystore.certificate", bundle.properties().getKeystore().getCertificate())); |
| 99 | + bundle.properties().getKeystore().getCertificates().stream() |
| 100 | + .map(location -> contentKeyStoreCertificateProperty.apply(location, "keystore.certificate")) |
| 101 | + .forEach(watched::add); |
97 | 102 | watched.add(new BundleContentProperty("truststore.private-key",
|
98 | 103 | bundle.properties().getTruststore().getPrivateKey()));
|
99 |
| - watched.add(new BundleContentProperty("truststore.certificate", |
100 |
| - bundle.properties().getTruststore().getCertificate())); |
| 104 | + bundle.properties().getTruststore().getCertificates().stream() |
| 105 | + .map(location -> contentKeyStoreCertificateProperty.apply(location, "truststore.certificate")) |
| 106 | + .forEach(watched::add); |
101 | 107 | return watchedPaths(bundle.name(), watched);
|
102 | 108 | }
|
103 | 109 |
|
| 110 | + private BiFunction<String, String, BundleContentProperty> locationToBundleContentProperty() { |
| 111 | + PemCertificateParser certificateParser = new PemCertificateParser(); |
| 112 | + return (location, name) -> { |
| 113 | + PemCertificate certificate = certificateParser.parse(location); |
| 114 | + return new BundleContentProperty(name, certificate.location(), certificate.optional()); |
| 115 | + }; |
| 116 | + } |
| 117 | + |
104 | 118 | private Set<WatchablePath> watchedPaths(String bundleName, List<BundleContentProperty> properties) {
|
105 | 119 | try {
|
106 | 120 | return properties.stream()
|
107 | 121 | .filter(BundleContentProperty::hasValue)
|
| 122 | + .filter(Predicate.not(BundleContentProperty::isPemContent)) |
108 | 123 | .map(BundleContentProperty::toWatchPath)
|
109 | 124 | .collect(Collectors.toSet());
|
110 | 125 | }
|
|
0 commit comments