【问题标题】:Configuring ssl keys for spring-cloud-config server为 spring-cloud-config 服务器配置 ssl 密钥
【发布时间】:2016-10-17 05:49:24
【问题描述】:

我想为 spring-cloud-config 服务器设置 server.ssl.key-store-password 并且配置将来自 GIT (application.yml)。

以下是我想在 application.yml 中配置的内容

server:
  port: 8760
  ssl:
    key-store: path to .jks
    key-store-password: '{cipher}encrypted password'
    key-store-type: jks
    key-password: '{cipher}encrypted password'

在引导配置服务器时,它使用 TextEncryptor FailsafeTextEncryptor 配置 EncryptionBootstrapConfiguration,当为​​ EnvironmentDecryptApplicationInitializer 调用解密函数时,它会失败。

我们如何为 EncryptionBootstrapConfiguration 自定义 TextEncryptor,以便我可以在启动配置服务器时使用 {cipher}

推荐https://stackoverflow.com/a/32047393/1946403

【问题讨论】:

  • 你有没有想过这个问题?我现在面临着完全相同的问题。

标签: spring-boot spring-cloud-netflix spring-cloud-config


【解决方案1】:

我收到了这个错误。为了解决这个问题,我不得不将 EncryptionConfiguration 和 TextEncryptor 添加到 spring.factory 文件中。

我有 3 个文件:

加密配置:

@Configuration
public class AESEncryptionConfiguration {

    @Bean
    EnvironmentDecryptApplicationInitializer environmentDecryptApplicationInitializer() {
        return new EnvironmentDecryptApplicationInitializer(new AESTextEncryptor());
    }
}

文本加密器:

@Component
public class AESTextEncryptor implements TextEncryptor {

    @Override
    public String encrypt(String text) {
        .
        .
        .       
    }

    @Override
    public String decrypt(String encryptedText) {
        .
        .
        .
    }
}

然后我必须在/src/main/resources/META-INF/spring.factories 中添加对这两个文件的引用

org.springframework.cloud.bootstrap.BootstrapConfiguration=com.rs.config.AESEncryptionConfiguration,com.common.encryption.AESTextEncryptor

通过这样做,我能够创建自定义密码。

【讨论】:

    猜你喜欢
    • 2016-06-26
    • 1970-01-01
    • 1970-01-01
    • 2017-04-06
    • 2019-01-27
    • 2015-07-13
    • 2015-10-28
    • 2017-01-27
    • 2017-02-23
    相关资源
    最近更新 更多