Skip to content

Conversation

@JiangHongTiao
Copy link

@JiangHongTiao JiangHongTiao commented Nov 28, 2023

This Pull Request introduces enhancements to the plugin to support using a custom TrustStore. This feature is crucial for fetching OpenAPI documentation over HTTPS in environments that utilize self-signed certificates, especially in local development setups.

Changes Made

  • TrustStore Configuration: Added properties trustStore and trustStorePassword to allow specifying a custom TrustStore.

  • SSL Context Adjustment: Modified the SSL context setup within the plugin to include the TrustStore, ensuring self-signed certificates are trusted during SSL handshakes. When TrustStore is not provided default SSL context is used.

Motivation

In our current setup, fetching OpenAPI documentation over HTTPS fails due to untrusted self-signed certificates. By enabling TrustStore configuration, developers can easily add their self-signed certificates to the TrustStore, circumventing the SSL handshake issue.

Testing

  • Tested fetching OpenAPI documentation in a local environment with a self-signed certificate, ensuring no SSL handshake errors occurred.
  • Verified backward compatibility and that the changes do not affect existing functionalities.
  • A new test case that validates the functionality of OpenAPI fetch using the TrustStore.

Usage

Set the new properties in the application's configuration to point to the custom TrustStore and its password:

openApi {
	apiDocsUrl.set("https://localhost:9000/api/docs")
	outputDir.set(file("$buildDir/docs"))
	outputFileName.set("swagger.json")
	waitTimeInSeconds.set(10)
	trustStore.set("keystore/truststore.p12")
	trustStorePassword.set("changeit".toCharArray())
	groupedApiMappings.set(
		["https://localhost:8080/v3/api-docs/groupA" to "swagger-groupA.json",
			"https://localhost:8080/v3/api-docs/groupB" to "swagger-groupB.json"]
	)
	customBootRun {
		args.set(["--spring.profiles.active=special"])
	}
}

Request for Review

I kindly request a thorough review of these changes, focusing particularly on the SSL context modifications and the implementation of the new properties. Any feedback or suggestions to further optimize this feature are welcome.

fixes #135

@bnasslahsen
Copy link
Contributor

@JiangHongTiao,

Thank you for your contribution to the project.
Will be merged soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support Truststore to Resolve SSL Handshake Failures with Self-Signed Certificates

2 participants