本文源码:https://github.com/axin1240101543/spring-cloud(有什么问题可以提issue给我,一起学习,共同进步。)
1、安装JCE
1.1、下载
1.2、替换
下载的jar文件:
jdk自带的文件:
路径:F:\Java\jdk1.8.0_151\jre\lib\security\policy\limited
2、Symmetric Encrypt
2.1、配置
2.2、加密
2.3、修改git配置文件
(yml和properties格式不同(yml有单引号、properties没有):key: '{cipher}密文' key= {cipher}密文)
详情请查看官方文档:
2.4、刷新配置
2.5、查看结果
3、Asymmetric Encrypt
3.1、生成秘钥库
keytool -genkeypair -alias mytestkey -keyalg RSA -dname "CN=Web Server,OU=Unit,O=Organization,L=City,S=State,C=US" -keypass changeme -keystore server.jks -storepass letmein
解析命令含义:
keytool -genkeypair -alias mytestkey -keyalg RSA -keypass changeme -keystore server.jks -storepass letmein
桌面生成jks文件:
Put the server.jks
file in the classpath (for instance) and then, in your bootstrap.yml
, for the Config Server, create the following settings:(将jks文件放入项目的resources目录下)
3.2、配置
3.3、加密
3.4、修改git配置文件
3.5、刷新配置
3.6、查看结果