【问题标题】:encryption in spring-cloud-config-serverspring-cloud-config-server 中的加密
【发布时间】:2016-12-22 21:09:32
【问题描述】:

我正在尝试使用 application.yml 中的加密属性运行 spring-cloud-config-server。

---

server:
  port: 8888  

spring:
  cloud:
    config:
      server:
        git:
          uri: file:/Users/gadams/git/cs-config

encrypt:
  key-store:
    location: classpath:/config-server.jks
    password: password
    alias: alias
    secret: secret

security:
  user:
    password: '{cipher}encryptedPassword'

我在启动时收到以下错误:

java.lang.IllegalStateException: Cannot decrypt: key=security.user.password
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:201) ~[spring-cloud-context-1.1.6.RELEASE.jar:1.1.6.RELEASE]
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:165) ~[spring-cloud-context-1.1.6.RELEASE.jar:1.1.6.RELEASE]
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.initialize(EnvironmentDecryptApplicationInitializer.java:95) ~[spring-cloud-context-1.1.6.RELEASE.jar:1.1.6.RELEASE]
    at org.springframework.cloud.bootstrap.BootstrapApplicationListener$DelegatingEnvironmentDecryptApplicationInitializer.initialize(BootstrapApplicationListener.java:333) ~[spring-cloud-context-1.1.6.RELEASE.jar:1.1.6.RELEASE]
    at org.springframework.boot.SpringApplication.applyInitializers(SpringApplication.java:635) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:349) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:313) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
    at com.collegescheduler.ConfigServerApplication.main(ConfigServerApplication.java:12) [bin/:na]
Caused by: java.lang.UnsupportedOperationException: No decryption for FailsafeTextEncryptor. Did you configure the keystore correctly?
    at org.springframework.cloud.bootstrap.encrypt.EncryptionBootstrapConfiguration$FailsafeTextEncryptor.decrypt(EncryptionBootstrapConfiguration.java:152) ~[spring-cloud-context-1.1.6.RELEASE.jar:1.1.6.RELEASE]
    at org.springframework.cloud.bootstrap.encrypt.EnvironmentDecryptApplicationInitializer.decrypt(EnvironmentDecryptApplicationInitializer.java:193) ~[spring-cloud-context-1.1.6.RELEASE.jar:1.1.6.RELEASE]
    ... 9 common frames omitted

我正在使用 org.springframework.cloud:spring-cloud-dependencies:Camden.SR3。应该如何加密配置服务器中的 spring-security 用户密码?

【问题讨论】:

  • 你检查我的答案了吗?

标签: password-encryption spring-cloud-config


【解决方案1】:

从日志中您的密钥库配置有问题。

首先使用keytool 验证您的密钥库的通行证/秘密/别名。

【讨论】:

  • 密钥库配置适用于来自 github 的配置中的加密属性。对于配置服务器的 application.yml 中的属性,它在引导阶段不起作用。
【解决方案2】:

你尊重prerequisites吗?

先决条件:使用加密和解密功能您需要 安装在您的 JVM 中的全功能 JCE(它不存在 默认)。您可以下载“Java 密码学扩展 (JCE) 来自 Oracle 的 Unlimited Strength Jurisdiction Policy Files”,并遵循 安装说明(基本上替换了 2 个策略文件 在 JRE lib/security 目录和您下载的目录中)。

你也应该在你的pom.xml:

<dependency>
    <groupId>org.springframework.security</groupId>
    <artifactId>spring-security-rsa</artifactId>
</dependency>

【讨论】:

    猜你喜欢
    • 2020-09-05
    • 2020-11-06
    • 2016-09-26
    • 1970-01-01
    • 1970-01-01
    • 2017-01-27
    • 2016-06-04
    • 2018-11-07
    • 1970-01-01
    相关资源
    最近更新 更多