16
16
17
17
package org .springframework .boot .actuate .autoconfigure .info ;
18
18
19
+ import java .time .Duration ;
19
20
import java .time .Instant ;
20
21
import java .util .List ;
21
22
import java .util .Properties ;
30
31
import org .springframework .boot .actuate .info .JavaInfoContributor ;
31
32
import org .springframework .boot .actuate .info .OsInfoContributor ;
32
33
import org .springframework .boot .actuate .info .ProcessInfoContributor ;
34
+ import org .springframework .boot .actuate .info .SslInfoContributor ;
33
35
import org .springframework .boot .info .BuildProperties ;
34
36
import org .springframework .boot .info .GitProperties ;
37
+ import org .springframework .boot .info .SslInfo ;
38
+ import org .springframework .boot .ssl .DefaultSslBundleRegistry ;
39
+ import org .springframework .boot .ssl .SslBundle ;
40
+ import org .springframework .boot .ssl .SslStoreBundle ;
41
+ import org .springframework .boot .ssl .jks .JksSslStoreBundle ;
42
+ import org .springframework .boot .ssl .jks .JksSslStoreDetails ;
35
43
import org .springframework .context .annotation .Bean ;
36
44
import org .springframework .context .annotation .Configuration ;
37
45
import org .springframework .restdocs .mockmvc .MockMvcRestDocumentation ;
@@ -55,7 +63,7 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
55
63
void info () {
56
64
assertThat (this .mvc .get ().uri ("/actuator/info" )).hasStatusOk ()
57
65
.apply (MockMvcRestDocumentation .document ("info" , gitInfo (), buildInfo (), osInfo (), processInfo (),
58
- javaInfo ()));
66
+ javaInfo (), sslInfo () ));
59
67
}
60
68
61
69
private ResponseFieldsSnippet gitInfo () {
@@ -166,6 +174,45 @@ private ResponseFieldsSnippet javaInfo() {
166
174
.optional ());
167
175
}
168
176
177
+ private ResponseFieldsSnippet sslInfo () {
178
+ return responseFields (beneathPath ("ssl" ),
179
+ fieldWithPath ("bundles" ).description ("SSL bundles information." ).type (JsonFieldType .ARRAY ),
180
+ fieldWithPath ("bundles[].name" ).description ("Name of the SSL bundle." ).type (JsonFieldType .STRING ),
181
+ fieldWithPath ("bundles[].certificateChains" ).description ("Certificate chains in the bundle." )
182
+ .type (JsonFieldType .ARRAY ),
183
+ fieldWithPath ("bundles[].certificateChains[].alias" ).description ("Alias of the certificate chain." )
184
+ .type (JsonFieldType .STRING ),
185
+ fieldWithPath ("bundles[].certificateChains[].certificates" ).description ("Certificates in the chain." )
186
+ .type (JsonFieldType .ARRAY ),
187
+ fieldWithPath ("bundles[].certificateChains[].certificates[].subject" )
188
+ .description ("Subject of the certificate." )
189
+ .type (JsonFieldType .STRING ),
190
+ fieldWithPath ("bundles[].certificateChains[].certificates[].version" )
191
+ .description ("Version of the certificate." )
192
+ .type (JsonFieldType .STRING ),
193
+ fieldWithPath ("bundles[].certificateChains[].certificates[].issuer" )
194
+ .description ("Issuer of the certificate." )
195
+ .type (JsonFieldType .STRING ),
196
+ fieldWithPath ("bundles[].certificateChains[].certificates[].validityStarts" )
197
+ .description ("Certificate validity start date." )
198
+ .type (JsonFieldType .STRING ),
199
+ fieldWithPath ("bundles[].certificateChains[].certificates[].serialNumber" )
200
+ .description ("Serial number of the certificate." )
201
+ .type (JsonFieldType .STRING ),
202
+ fieldWithPath ("bundles[].certificateChains[].certificates[].validityEnds" )
203
+ .description ("Certificate validity end date." )
204
+ .type (JsonFieldType .STRING ),
205
+ fieldWithPath ("bundles[].certificateChains[].certificates[].validity" )
206
+ .description ("Certificate validity information." )
207
+ .type (JsonFieldType .OBJECT ),
208
+ fieldWithPath ("bundles[].certificateChains[].certificates[].validity.status" )
209
+ .description ("Certificate validity status." )
210
+ .type (JsonFieldType .STRING ),
211
+ fieldWithPath ("bundles[].certificateChains[].certificates[].signatureAlgorithmName" )
212
+ .description ("Signature algorithm name." )
213
+ .type (JsonFieldType .STRING ));
214
+ }
215
+
169
216
@ Configuration (proxyBeanMethods = false )
170
217
static class TestConfiguration {
171
218
@@ -210,6 +257,21 @@ JavaInfoContributor javaInfoContributor() {
210
257
return new JavaInfoContributor ();
211
258
}
212
259
260
+ @ Bean
261
+ SslInfo sslInfo () {
262
+ DefaultSslBundleRegistry sslBundleRegistry = new DefaultSslBundleRegistry ();
263
+ JksSslStoreDetails keyStoreDetails = JksSslStoreDetails .forLocation ("classpath:test.p12" )
264
+ .withPassword ("secret" );
265
+ SslStoreBundle sslStoreBundle = new JksSslStoreBundle (keyStoreDetails , null );
266
+ sslBundleRegistry .registerBundle ("test-0" , SslBundle .of (sslStoreBundle ));
267
+ return new SslInfo (sslBundleRegistry , Duration .ofDays (7 ));
268
+ }
269
+
270
+ @ Bean
271
+ SslInfoContributor sslInfoContributor (SslInfo sslInfo ) {
272
+ return new SslInfoContributor (sslInfo );
273
+ }
274
+
213
275
}
214
276
215
277
}
0 commit comments