1616
1717package org .springframework .boot .actuate .autoconfigure .info ;
1818
19+ import java .time .Duration ;
1920import java .time .Instant ;
2021import java .util .List ;
2122import java .util .Properties ;
3031import org .springframework .boot .actuate .info .JavaInfoContributor ;
3132import org .springframework .boot .actuate .info .OsInfoContributor ;
3233import org .springframework .boot .actuate .info .ProcessInfoContributor ;
34+ import org .springframework .boot .actuate .info .SslInfoContributor ;
3335import org .springframework .boot .info .BuildProperties ;
3436import 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 ;
3543import org .springframework .context .annotation .Bean ;
3644import org .springframework .context .annotation .Configuration ;
3745import org .springframework .restdocs .mockmvc .MockMvcRestDocumentation ;
@@ -55,7 +63,7 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
5563 void info () {
5664 assertThat (this .mvc .get ().uri ("/actuator/info" )).hasStatusOk ()
5765 .apply (MockMvcRestDocumentation .document ("info" , gitInfo (), buildInfo (), osInfo (), processInfo (),
58- javaInfo ()));
66+ javaInfo (), sslInfo () ));
5967 }
6068
6169 private ResponseFieldsSnippet gitInfo () {
@@ -142,6 +150,45 @@ private ResponseFieldsSnippet javaInfo() {
142150 .optional ());
143151 }
144152
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+
145192 @ Configuration (proxyBeanMethods = false )
146193 static class TestConfiguration {
147194
@@ -186,6 +233,21 @@ JavaInfoContributor javaInfoContributor() {
186233 return new JavaInfoContributor ();
187234 }
188235
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+
189251 }
190252
191253}
0 commit comments