From 4c53755980dadda5e8d8b825ad65369d56df072d Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 18 Sep 2017 16:43:49 +0200 Subject: [PATCH] Polish "Added keystore type and truststore type to rabbit properties" Closes gh-10251 --- .../boot/autoconfigure/amqp/RabbitAutoConfiguration.java | 8 ++------ .../boot/autoconfigure/amqp/RabbitProperties.java | 8 ++++---- .../autoconfigure/amqp/RabbitAutoConfigurationTests.java | 6 +++--- .../main/asciidoc/appendix-application-properties.adoc | 4 ++-- 4 files changed, 11 insertions(+), 15 deletions(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java index 2b849b5066..38532b0adc 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfiguration.java @@ -113,14 +113,10 @@ public class RabbitAutoConfiguration { if (ssl.getAlgorithm() != null) { factory.setSslAlgorithm(ssl.getAlgorithm()); } - if (ssl.getKeyStoreType() != null) { - factory.setKeyStoreType(ssl.getKeyStoreType()); - } + factory.setKeyStoreType(ssl.getKeyStoreType()); factory.setKeyStore(ssl.getKeyStore()); factory.setKeyStorePassphrase(ssl.getKeyStorePassword()); - if (ssl.getTrustStoreType() != null) { - factory.setTrustStoreType(ssl.getTrustStoreType()); - } + factory.setTrustStoreType(ssl.getTrustStoreType()); factory.setTrustStore(ssl.getTrustStore()); factory.setTrustStorePassphrase(ssl.getTrustStorePassword()); } diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java index 2b57df1cd1..8d2fe9afd1 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/amqp/RabbitProperties.java @@ -315,9 +315,9 @@ public class RabbitProperties { private String keyStore; /** - * Set the key store type (jks, pkcs12, etc). + * Key store type. */ - private String keyStoreType; + private String keyStoreType = "PKCS12"; /** * Password used to access the key store. @@ -330,9 +330,9 @@ public class RabbitProperties { private String trustStore; /** - * Set the trust store type (jks, pkcs12, etc). + * Trust store type. */ - private String trustStoreType; + private String trustStoreType = "JKS"; /** * Password used to access the trust store. diff --git a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java index 782c426b28..4e116b6025 100644 --- a/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java +++ b/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/amqp/RabbitAutoConfigurationTests.java @@ -542,7 +542,7 @@ public class RabbitAutoConfigurationTests { @Test // Make sure that we at least attempt to load the store - public void enableSslWithNonexistingKeystoreShouldFail() { + public void enableSslWithNonExistingKeystoreShouldFail() { this.contextRunner .withUserConfiguration(TestConfiguration.class) .withPropertyValues("spring.rabbitmq.ssl.enabled:true", @@ -557,7 +557,7 @@ public class RabbitAutoConfigurationTests { @Test // Make sure that we at least attempt to load the store - public void enableSslWithNonexistingTruststoreShouldFail() { + public void enableSslWithNonExistingTrustStoreShouldFail() { this.contextRunner .withUserConfiguration(TestConfiguration.class) .withPropertyValues( @@ -587,7 +587,7 @@ public class RabbitAutoConfigurationTests { } @Test - public void enableSslWithInvalidTruststoreTypeShouldFail() throws Exception { + public void enableSslWithInvalidTrustStoreTypeShouldFail() throws Exception { this.contextRunner .withUserConfiguration(TestConfiguration.class) .withPropertyValues( diff --git a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc index 3e5e7acf3c..8c0e997ac3 100644 --- a/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc +++ b/spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc @@ -1051,11 +1051,11 @@ content into your application; rather pick only the properties that you need. spring.rabbitmq.requested-heartbeat= # Requested heartbeat timeout, in seconds; zero for none. spring.rabbitmq.ssl.enabled=false # Enable SSL support. spring.rabbitmq.ssl.key-store= # Path to the key store that holds the SSL certificate. - spring.rabbitmq.ssl.key-store-type= # Type of key store (jks, pkcs12,..). Defaults to pkcs12 if not set spring.rabbitmq.ssl.key-store-password= # Password used to access the key store. + spring.rabbitmq.ssl.key-store-type=PKCS12 # Key store type. spring.rabbitmq.ssl.trust-store= # Trust store that holds SSL certificates. - spring.rabbitmq.ssl.trust-store-type= # Type of trust store (jks, pkcs12,..). Defaults to jks if not set spring.rabbitmq.ssl.trust-store-password= # Password used to access the trust store. + spring.rabbitmq.ssl.trust-store-type=JKS # Trust store type. spring.rabbitmq.ssl.algorithm= # SSL algorithm to use. By default configure by the rabbit client library. spring.rabbitmq.template.mandatory=false # Enable mandatory messages. spring.rabbitmq.template.receive-timeout=0 # Timeout for `receive()` methods.