Skip to content

Commit 65df30f

Browse files
authored
fixes gh-953 (#963)
1 parent 28d0bc4 commit 65df30f

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,8 +120,8 @@ public static TextEncryptor createTextEncryptor(KeyProperties keyProperties, Rsa
120120
if (keyStore.getLocation() != null) {
121121
if (keyStore.getLocation().exists()) {
122122
return new RsaSecretEncryptor(
123-
new KeyStoreKeyFactory(keyStore.getLocation(), keyStore.getPassword().toCharArray())
124-
.getKeyPair(keyStore.getAlias(), keyStore.getSecret().toCharArray()),
123+
new KeyStoreKeyFactory(keyStore.getLocation(), keyStore.getPassword().toCharArray(),
124+
keyStore.getType()).getKeyPair(keyStore.getAlias(), keyStore.getSecret().toCharArray()),
125125
rsaProperties.getAlgorithm(), rsaProperties.getSalt(), rsaProperties.isStrong());
126126
}
127127

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@ public void rsaKeyStore() {
4949
context.close();
5050
}
5151

52+
@Test
53+
public void rsaPkcs12KeyStore() {
54+
ConfigurableApplicationContext context = new SpringApplicationBuilder(EncryptionBootstrapConfiguration.class)
55+
.web(WebApplicationType.NONE)
56+
.properties("encrypt.keyStore.location:classpath:/server.p12", "encrypt.keyStore.password:letmein",
57+
"encrypt.keyStore.alias:mytestkey", "encrypt.keyStore.type:PKCS12")
58+
.run();
59+
TextEncryptor encryptor = context.getBean(TextEncryptor.class);
60+
then(encryptor.decrypt(encryptor.encrypt("foo"))).isEqualTo("foo");
61+
context.close();
62+
}
63+
5264
@Test
5365
public void rsaKeyStoreWithRelaxedProperties() {
5466
ConfigurableApplicationContext context = new SpringApplicationBuilder(EncryptionBootstrapConfiguration.class)
2.36 KB
Binary file not shown.

0 commit comments

Comments
 (0)