Skip to content

Add SSL response structure to actuator info endpoint documentation #45792

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,13 @@ The following table describes the structure of the `java` section of the respons

[cols="2,1,3"]
include::partial$rest/actuator/info/response-fields-beneath-java.adoc[]



[[info.retrieving.response-structure.ssl]]
==== SSL Response Structure

The following table describes the structure of the `ssl` section of the response:

[cols="2,1,3"]
include::partial$rest/actuator/info/response-fields-beneath-ssl.adoc[]
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.springframework.boot.actuate.autoconfigure.info;

import java.time.Duration;
import java.time.Instant;
import java.util.List;
import java.util.Properties;
Expand All @@ -30,8 +31,15 @@
import org.springframework.boot.actuate.info.JavaInfoContributor;
import org.springframework.boot.actuate.info.OsInfoContributor;
import org.springframework.boot.actuate.info.ProcessInfoContributor;
import org.springframework.boot.actuate.info.SslInfoContributor;
import org.springframework.boot.info.BuildProperties;
import org.springframework.boot.info.GitProperties;
import org.springframework.boot.info.SslInfo;
import org.springframework.boot.ssl.DefaultSslBundleRegistry;
import org.springframework.boot.ssl.SslBundle;
import org.springframework.boot.ssl.SslStoreBundle;
import org.springframework.boot.ssl.jks.JksSslStoreBundle;
import org.springframework.boot.ssl.jks.JksSslStoreDetails;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.restdocs.mockmvc.MockMvcRestDocumentation;
Expand All @@ -55,7 +63,7 @@ class InfoEndpointDocumentationTests extends MockMvcEndpointDocumentationTests {
void info() {
assertThat(this.mvc.get().uri("/actuator/info")).hasStatusOk()
.apply(MockMvcRestDocumentation.document("info", gitInfo(), buildInfo(), osInfo(), processInfo(),
javaInfo()));
javaInfo(), sslInfo()));
}

private ResponseFieldsSnippet gitInfo() {
Expand Down Expand Up @@ -142,6 +150,45 @@ private ResponseFieldsSnippet javaInfo() {
.optional());
}

private ResponseFieldsSnippet sslInfo() {
return responseFields(beneathPath("ssl"),
fieldWithPath("bundles").description("SSL bundles information.").type(JsonFieldType.ARRAY),
fieldWithPath("bundles[].name").description("Name of the SSL bundle.").type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains").description("Certificate chains in the bundle.")
.type(JsonFieldType.ARRAY),
fieldWithPath("bundles[].certificateChains[].alias").description("Alias of the certificate chain.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates").description("Certificates in the chain.")
.type(JsonFieldType.ARRAY),
fieldWithPath("bundles[].certificateChains[].certificates[].subject")
.description("Subject of the certificate.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].version")
.description("Version of the certificate.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].issuer")
.description("Issuer of the certificate.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].validityStarts")
.description("Certificate validity start date.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].serialNumber")
.description("Serial number of the certificate.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].validityEnds")
.description("Certificate validity end date.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].validity")
.description("Certificate validity information.")
.type(JsonFieldType.OBJECT),
fieldWithPath("bundles[].certificateChains[].certificates[].validity.status")
.description("Certificate validity status.")
.type(JsonFieldType.STRING),
fieldWithPath("bundles[].certificateChains[].certificates[].signatureAlgorithmName")
.description("Signature algorithm name.")
.type(JsonFieldType.STRING));
}

@Configuration(proxyBeanMethods = false)
static class TestConfiguration {

Expand Down Expand Up @@ -186,6 +233,21 @@ JavaInfoContributor javaInfoContributor() {
return new JavaInfoContributor();
}

@Bean
SslInfo sslInfo() {
DefaultSslBundleRegistry sslBundleRegistry = new DefaultSslBundleRegistry();
JksSslStoreDetails keyStoreDetails = JksSslStoreDetails.forLocation("classpath:test.p12")
.withPassword("secret");
SslStoreBundle sslStoreBundle = new JksSslStoreBundle(keyStoreDetails, null);
sslBundleRegistry.registerBundle("test-0", SslBundle.of(sslStoreBundle));
return new SslInfo(sslBundleRegistry, Duration.ofDays(7));
}

@Bean
SslInfoContributor sslInfoContributor(SslInfo sslInfo) {
return new SslInfoContributor(sslInfo);
}

}

}
Binary file not shown.