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 () {
@@ -142,6 +150,45 @@ private ResponseFieldsSnippet javaInfo() {
142
150
.optional ());
143
151
}
144
152
153
+ private ResponseFieldsSnippet sslInfo () {
154
+ return responseFields (beneathPath ("ssl" ),
155
+ fieldWithPath ("bundles" ).description ("SSL bundles information." ).type (JsonFieldType .ARRAY ),
156
+ fieldWithPath ("bundles[].name" ).description ("Name of the SSL bundle." ).type (JsonFieldType .STRING ),
157
+ fieldWithPath ("bundles[].certificateChains" ).description ("Certificate chains in the bundle." )
158
+ .type (JsonFieldType .ARRAY ),
159
+ fieldWithPath ("bundles[].certificateChains[].alias" ).description ("Alias of the certificate chain." )
160
+ .type (JsonFieldType .STRING ),
161
+ fieldWithPath ("bundles[].certificateChains[].certificates" ).description ("Certificates in the chain." )
162
+ .type (JsonFieldType .ARRAY ),
163
+ fieldWithPath ("bundles[].certificateChains[].certificates[].subject" )
164
+ .description ("Subject of the certificate." )
165
+ .type (JsonFieldType .STRING ),
166
+ fieldWithPath ("bundles[].certificateChains[].certificates[].version" )
167
+ .description ("Version of the certificate." )
168
+ .type (JsonFieldType .STRING ),
169
+ fieldWithPath ("bundles[].certificateChains[].certificates[].issuer" )
170
+ .description ("Issuer of the certificate." )
171
+ .type (JsonFieldType .STRING ),
172
+ fieldWithPath ("bundles[].certificateChains[].certificates[].validityStarts" )
173
+ .description ("Certificate validity start date." )
174
+ .type (JsonFieldType .STRING ),
175
+ fieldWithPath ("bundles[].certificateChains[].certificates[].serialNumber" )
176
+ .description ("Serial number of the certificate." )
177
+ .type (JsonFieldType .STRING ),
178
+ fieldWithPath ("bundles[].certificateChains[].certificates[].validityEnds" )
179
+ .description ("Certificate validity end date." )
180
+ .type (JsonFieldType .STRING ),
181
+ fieldWithPath ("bundles[].certificateChains[].certificates[].validity" )
182
+ .description ("Certificate validity information." )
183
+ .type (JsonFieldType .OBJECT ),
184
+ fieldWithPath ("bundles[].certificateChains[].certificates[].validity.status" )
185
+ .description ("Certificate validity status." )
186
+ .type (JsonFieldType .STRING ),
187
+ fieldWithPath ("bundles[].certificateChains[].certificates[].signatureAlgorithmName" )
188
+ .description ("Signature algorithm name." )
189
+ .type (JsonFieldType .STRING ));
190
+ }
191
+
145
192
@ Configuration (proxyBeanMethods = false )
146
193
static class TestConfiguration {
147
194
@@ -186,6 +233,21 @@ JavaInfoContributor javaInfoContributor() {
186
233
return new JavaInfoContributor ();
187
234
}
188
235
236
+ @ Bean
237
+ SslInfo sslInfo () {
238
+ DefaultSslBundleRegistry sslBundleRegistry = new DefaultSslBundleRegistry ();
239
+ JksSslStoreDetails keyStoreDetails = JksSslStoreDetails .forLocation ("classpath:test.p12" )
240
+ .withPassword ("secret" );
241
+ SslStoreBundle sslStoreBundle = new JksSslStoreBundle (keyStoreDetails , null );
242
+ sslBundleRegistry .registerBundle ("test-0" , SslBundle .of (sslStoreBundle ));
243
+ return new SslInfo (sslBundleRegistry , Duration .ofDays (7 ));
244
+ }
245
+
246
+ @ Bean
247
+ SslInfoContributor sslInfoContributor (SslInfo sslInfo ) {
248
+ return new SslInfoContributor (sslInfo );
249
+ }
250
+
189
251
}
190
252
191
253
}
0 commit comments