Browse Source

fixes gh-953 (#963)

pull/966/head
bberto 4 years ago committed by GitHub
parent
commit
65df30f420
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/TextEncryptorUtils.java
  2. 12
      spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfigurationTests.java
  3. BIN
      spring-cloud-context/src/test/resources/server.p12

4
spring-cloud-context/src/main/java/org/springframework/cloud/bootstrap/encrypt/TextEncryptorUtils.java

@ -120,8 +120,8 @@ public abstract class TextEncryptorUtils { @@ -120,8 +120,8 @@ public abstract class TextEncryptorUtils {
if (keyStore.getLocation() != null) {
if (keyStore.getLocation().exists()) {
return new RsaSecretEncryptor(
new KeyStoreKeyFactory(keyStore.getLocation(), keyStore.getPassword().toCharArray())
.getKeyPair(keyStore.getAlias(), keyStore.getSecret().toCharArray()),
new KeyStoreKeyFactory(keyStore.getLocation(), keyStore.getPassword().toCharArray(),
keyStore.getType()).getKeyPair(keyStore.getAlias(), keyStore.getSecret().toCharArray()),
rsaProperties.getAlgorithm(), rsaProperties.getSalt(), rsaProperties.isStrong());
}

12
spring-cloud-context/src/test/java/org/springframework/cloud/bootstrap/encrypt/EncryptionBootstrapConfigurationTests.java

@ -49,6 +49,18 @@ public class EncryptionBootstrapConfigurationTests { @@ -49,6 +49,18 @@ public class EncryptionBootstrapConfigurationTests {
context.close();
}
@Test
public void rsaPkcs12KeyStore() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(EncryptionBootstrapConfiguration.class)
.web(WebApplicationType.NONE)
.properties("encrypt.keyStore.location:classpath:/server.p12", "encrypt.keyStore.password:letmein",
"encrypt.keyStore.alias:mytestkey", "encrypt.keyStore.type:PKCS12")
.run();
TextEncryptor encryptor = context.getBean(TextEncryptor.class);
then(encryptor.decrypt(encryptor.encrypt("foo"))).isEqualTo("foo");
context.close();
}
@Test
public void rsaKeyStoreWithRelaxedProperties() {
ConfigurableApplicationContext context = new SpringApplicationBuilder(EncryptionBootstrapConfiguration.class)

BIN
spring-cloud-context/src/test/resources/server.p12

Binary file not shown.
Loading…
Cancel
Save