简体   繁体   English

Java:将加密的数据库(和其他)密码存储在属性文件中的最佳选择是什么?

[英]Java: What is the best option to store encrypted database (and other) passwords in property files?

I examine Jasypt for storing database encrypted passwords in property files. 我检查了Jasypt在属性文件中存储数据库加密密码的情况。 It has good integration with Spring etc., but approach of that this guys propose for encrypting password looks a bit weird as for me: 它与Spring等具有很好的集成性,但是这些家伙提议的用于加密密码的方法对我来说有点奇怪:

  1. Use PBE (symmetric algorithm) encryption. 使用PBE(对称算法)加密。

  2. Store password for encryption/decryption in environment variable or in source code. 在环境变量或源代码中存储用于加密/解密的密码。

Both options look unsafe and a bit insecure. 这两个选项看起来都不安全,并且有点不安全。

My questions: 我的问题:

  1. What is the best practice for storing encrypted passwords? 存储加密密码的最佳做法是什么?
  2. Can I use key based encryption (ie private/public keys) here? 我可以在这里使用基于密钥的加密(即私钥/公钥)吗?

In our application we use two approaches: 在我们的应用程序中,我们使用两种方法:

  1. We use a enterprise password vault which stores the passwords for all our databases. 我们使用企业密码库来存储我们所有数据库的密码。 Our web sever requests the password from the vault to connect the database every time. 我们的Web服务器每次都从Vault请求密码来连接数据库。

  2. We store Encrypted passwords in properties file. 我们将加密密码存储在属性文件中。 And during the application startup we read the properties file using class loader and keep it as a system variable and use it whenever needed. 在应用程序启动期间,我们使用类加载器读取属性文件,并将其保留为系统变量,并在需要时使用它。

It is difficult to have public/private key encryption directly with db, you would need an intermediary to do this. 直接使用db进行公钥/私钥加密是很困难的,您需要中介才能做到这一点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM