我使用了this project from spring.io并通过使用以下属性文件添加了非对称加密和解密。
<code>
application properties (server side) :
server.port=8888
spring.cloud.config.server.git.uri=https://{uname}:{password}@{giturl}
encrypt.key-store.location=classpath:/server.jks
encrypt.key-store.password=letmein
encrypt.key-store.alias=mytestkey
encrypt.key-store.secret=changeme
spring.cloud.config.server.encrypt.enabled=false
security.user.name=root
security.user.password=s3cr3t
</code>
<code>
bootstrap.properties (client side) :
spring.application.name=config-client
spring.cloud.config.uri=http://root:s3cr3t@localhost:8888
encrypt.key-store.location=classpath:/server.jks
encrypt.key-store.password=letmein
encrypt.key-store.alias=mytestkey
encrypt.key-store.secret=changeme
server.port=8089
</code>
我的git中的属性文件有
<code>
message={cipher}{key:mytestkey}AQA5...
</code>
不幸的是,我在Spring RestController
类中获取了加密消息,该类位于Spring Boot应用程序中。
<code>
@RefreshScope
@RestController
class MessageRestController {
@Value("${message}")
private String message;
@RequestMapping("/message")
String getMessage() {
return this.message;
}
}
</code>
我错过了解密的东西吗?