spring-cloud-config-server 总是解密加密的消息?

spring-cloud-config-server alway decrypt the encrypted message?

我正在运行宁spring云配置server.I遵循用户指南,并成功启动它,它可以从github加载配置config-repo/licensingservice/licensingservice.yml 。我可以使用 /decrypt 和 /encript 端点,但是当我 运行 http://localhost:8888/licensingservice/default 它总是解密敏感信息 spring.datasource.password: "{cipher}4788dfe1ccbe6485934aec2ffeddb06163ea3d616df5fd75be96aadd4df1da91"进入 "spring.datasource.password": "p0stgr@s" 我把spring.cloud.config.server.encrypt.enabled=false放在了bootstrap.yml里,通过

可以看到
localhost:8888/actuator/env

github上的配置:

    example.property: "I AM IN THE DEFAULT"
spring.jpa.database: "POSTGRESQL"
spring.datasource.platform:  "postgres"
spring.jpa.show-sql: "true"
spring.database.driverClassName: "org.postgresql.Driver"
spring.datasource.url: "jdbc:postgresql://database:5432/eagle_eye_local"
spring.datasource.username: "postgres"
spring.datasource.password: "{cipher}4788dfe1ccbe6485934aec2ffeddb06163ea3d616df5fd75be96aadd4df1da91"
spring.datasource.testWhileIdle: "true"
spring.datasource.validationQuery: "SELECT 1"
spring.jpa.properties.hibernate.dialect: "org.hibernate.dialect.PostgreSQLDialect"
redis.server: "redis"
redis.port: "6379"
signing.key: "345345fsdfsf5345"

配置从邮递员处获取:

{
    "name": "licensingservice",
    "profiles": [
        "default"
    ],
    "label": null,
    "version": "56d63a8c0c3dcb0c5c93db1f00cf71856371db8b",
    "state": null,
    "propertySources": [
        {
            "name": "https://github.com/carnellj/config-repo//licensingservice/licensingservice.yml",
            "source": {
                "example.property": "I AM IN THE DEFAULT",
                "spring.jpa.database": "POSTGRESQL",
                "spring.datasource.platform": "postgres",
                "spring.jpa.show-sql": "true",
                "spring.database.driverClassName": "org.postgresql.Driver",
                "spring.datasource.url": "jdbc:postgresql://database:5432/eagle_eye_local",
                "spring.datasource.username": "postgres",
                "spring.datasource.testWhileIdle": "true",
                "spring.datasource.validationQuery": "SELECT 1",
                "spring.jpa.properties.hibernate.dialect": "org.hibernate.dialect.PostgreSQLDialect",
                "redis.server": "redis",
                "redis.port": "6379",
                "signing.key": "345345fsdfsf5345",
                "spring.datasource.password": "p0stgr@s"
            }
        }
    ]
}

我的构建脚本:

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
    id("org.springframework.boot") version "2.3.1.RELEASE"
    id("io.spring.dependency-management") version "1.0.9.RELEASE"
    kotlin("jvm") version "1.3.72"
    kotlin("plugin.spring") version "1.3.72"
}

group = "com.matches"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8

repositories {
    mavenCentral()
}

extra["springCloudVersion"] = "Hoxton.SR6"

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-reflect")
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
    implementation("org.springframework.cloud:spring-cloud-config-server")
    implementation("org.springframework.cloud:spring-cloud-starter-config")
    implementation("org.springframework.cloud:spring-cloud-starter-eureka")
    implementation("org.springframework.boot:spring-boot-starter-actuator")
    testImplementation("org.springframework.boot:spring-boot-starter-test") {
        exclude(group = "org.junit.vintage", module = "junit-vintage-engine")
    }
}

dependencyManagement {
    imports {
        mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
    }
}

tasks.withType<Test> {
    useJUnitPlatform()
}

tasks.withType<KotlinCompile> {
    kotlinOptions {
        freeCompilerArgs = listOf("-Xjsr305=strict")
        jvmTarget = "1.8"
    }
}

配置服务器应用:

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.cloud.config.server.EnableConfigServer

@SpringBootApplication
@EnableConfigServer
class ConfigserverApplication

fun main(args: Array<String>) {
    runApplication<ConfigserverApplication>(*args)
}

为什么老是解密码我怎么也找不到?

spring-cloud-config-server 总是解密加密的消息? NO

ConfigClient如果我们在ConfigServer中设置encryptfalse也可以解密。

spring:
  cloud:
    config:
      server:
        encrypt:
          enabled: false
        git:
          uri: linkToYourURI

并且在 ConfigClient 中使用这样的密钥进行解密。 记得把这个放在bootstrap.yml里,至于application.yml就来不及了,看这个.

encrypt:
  key: PutYourKeyHere