日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > javascript >内容正文

javascript

微服务SpringCloud—Config Server对称加密

發布時間:2025/6/17 javascript 44 豆豆
生活随笔 收集整理的這篇文章主要介紹了 微服务SpringCloud—Config Server对称加密 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

配置內容的加解密
在Git倉庫中明文存儲配置屬性的。很多場景下,對于某些敏感的配置內容(例如數據庫賬號、密碼等),應當加密存儲。

Config對稱加解密
1、安裝JCE
默認情況下我們的JRE自帶了JCE,但是默認是一個有限長度的版本,需要到oracle官網下載一個不限長度的JCE。

JCE下載地址
https://www.oracle.com/technetwork/java/javase/downloads/jce-all-download-5170447.html

下載JCE并解壓(eg:jce_policy-8.zip),按照其中的README.txt的說明安裝。

JCE的安裝非常簡單,其實就是將JDK/jre/lib/security目錄中的兩個jar文件(local_policy.jar、US_export_policy.jar)替換為壓縮包中的jar文件。

2、在config server服務的bootstrap.yml文件中配置對稱密匙

#博客:https://blog.csdn.net/u014296316/article/details/80881974 #http://localhost:6063/encrypt/status 驗證加密解密功能是否正常 #http://localhost:6063/encrypt 只允許post請求 #http://localhost:6063/decrypt 只允許post請求 encrypt:key: Lynch

?

3、訪問 http://localhost:6063/encrypt/status 驗證加密解密功能是否正常

4、訪問/encrypt和/decrypt進行加密解密
http://localhost:6063/encrypt 只允許post請求

http://localhost:6063/decrypt 只允許post請求

5、配置文件中使用{cipher}開頭標識加密數據

6、在Config Client服務獲取加密數據

import org.springframework.beans.factory.annotation.Value; import org.springframework.cloud.context.config.annotation.RefreshScope; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController;/*** 這邊的@RefreshScope注解不能少,否則即使調用/refresh,配置也不會刷新*/ @RestController @RefreshScope public class ConfigClientController {@Value("${env}")private String env;@Value("${password}")private String password;@Value("${username}")private String username;@GetMapping("/config/profile")public String hello() {return this.env+","+this.password+","+this.username;} }

?

?

http://localhost:6062/config/profile

轉載于:https://www.cnblogs.com/linjiqin/p/10338588.html

總結

以上是生活随笔為你收集整理的微服务SpringCloud—Config Server对称加密的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。