spring cloud config encryption usage

spring cloud config encryption uses

data that is not encrypted on git, which is more dangerous. After
encryption , you can let the config server decrypt it, which will be safer

. Download Java 8 JCE (the default version is the length-limited version, so use this)
http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html

is actually to replace the two jar files in the JDK/jre/lib/security directory with the jar files in JCE.


The curl tool is installed
on the official website to download the toolkit: http://curl.haxx.se/download.html





Of course, you can add the environment variable of the curl command to Windows, increase the CURL_HOME environment variable, and add %CURL_HOME% to the PATH environment variable; 
This will allow you to use the curl command from any directory in the command window.






The content of the file on git is updated to
configClient-test.properties

#cipher indicates encrypted
foo = {cipher}dda7913d685b9201241907150244ed055c2f69d6f6bb6d21ddbf1764ce070fbc





<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
	http://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>


	<groupId>com.midea</groupId>
	<artifactId>base</artifactId>
	<version>1.0-SNAPSHOT</version>
	<packaging>jar</packaging>
	<name>base</name>


	<!-- Set the warehouse, search according to the set order. -->
	<!--<repositories> <repository> <id>public</id> <name>Team Nexus Repository</name>
		<url>http://10.33.183.113:8081/nexus/content/groups/public</url> <snapshots>
		<enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots>
		</repository> </repositories> <pluginRepositories> <pluginRepository> <id>public</id>
		<name>Team Nexus Repository</name> <url>http://10.33.183.113:8081/nexus/content/groups/public</url>
		<snapshots> <enabled>true</enabled> <updatePolicy>always</updatePolicy> </snapshots>
		</pluginRepository> </pluginRepositories> -->

	<properties>
		<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
		<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
		<java.version>1.8</java.version>
	</properties>

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.5.2.RELEASE</version>
	</parent>

	<dependencyManagement>
		<dependencies>
			<dependency>
				<groupId>org.springframework.cloud</groupId>
				<artifactId>spring-cloud-dependencies</artifactId>
				<version>Dalston.SR1</version>
				<type>pom</type>
				<scope>import</scope>
			</dependency>
		</dependencies>
	</dependencyManagement>

	<dependencies>
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-config</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-config-server</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>

		<!-- <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-security</artifactId>
		</dependency> -->

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-actuator</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-starter-eureka</artifactId>
		</dependency>

		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger2</artifactId>
			<version>2.4.0</version>
			<exclusions>
				<exclusion>
					<groupId>org.slf4j</groupId>
					<artifactId>slf4j-api</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>io.springfox</groupId>
			<artifactId>springfox-swagger-ui</artifactId>
			<version>2.4.0</version>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-log4j2</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<exclusions>
				<exclusion>
					<groupId>org.springframework.boot</groupId>
					<artifactId>spring-boot-starter-logging</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
	</dependencies>
	<build>

	</build>
</project>






server.port=8888


#server path
#server.context-path=/eurekaServer

spring.application.name=config-server

#gitHub path
spring.cloud.config.server.git.uri=https://github.com/huangyongxing310/springCloudConfigTest.git
#File path, if it is the root directory, it can not be configured
spring.cloud.config.server.git.searchPaths=test
#Configure the branch of the repository,
spring.cloud.config.label=master
#gitHub account password
[email protected]
spring.cloud.config.server.git.password=xing310600

#securitySecurity Mechanisms
security.user.name=user
security.user.password=123456

eureka.client.serviceUrl.defaultZone=http://localhost:8761/eurekaServer/eureka/

# set symmetric key
encrypt.key=123456



package com;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;



@SpringBootApplication //spring boot starts the application
@EnableConfigServer //Indicates that the Config service is enabled
@EnableEurekaClient //Only for eureka
public class Application {

	public static void main(String[] args) {
		SpringApplication.run(Application.class, args);
	}

}






http://localhost:8888/encrypt/status

curl http://localhost:8888/encrypt -d 123456
curl http://localhost:8888/decrypt -d dda7913d685b9201241907150244ed055c2f69d6f6bb6d21ddbf1764ce070fbc






Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326540320&siteId=291194637