Jasypt StandardPBEStringEncryptor 在 spring bean 配置文件中设置密码

发布于 2024-09-10 15:18:31 字数 128 浏览 6 评论 0原文

当使用 Jasypt 的 StandardPBEStringEncryptor 时,我们必须在 spring bean 配置文件中显式设置密码。将密码放在 bean 配置文件中是否可以且安全?存储加密器密码是否会导致 PCI 合规性出现问题?

When using Jasypt's StandardPBEStringEncryptor we have to set password explicitly in spring bean configuration file. Is it ok and secure to have the password in the bean configuration file? Will it be a problem in PCI Compliance to store the encryptor password?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你另情深 2024-09-17 15:18:31

符合 PCI 标准。数据加密密钥不能以明文形式存储。具体点是3.5.2,即:

检查系统配置文件以
验证密钥是否存储在
加密格式,并且
存储密钥加密密钥
与数据加密密钥分开。

您可能还会遇到有关密钥管理领域的其他问题,例如 3.6.6(密钥分割知识和双重控制)

验证密钥管理程序
实施要求拆分
按键知识和双重控制
(例如,需要两个或三个
人,每个人都只知道自己的
密钥的一部分,重建
整个钥匙)。

密钥管理是 PCI 合规性中最具挑战性的部分。您可能需要考虑使用(已符合 PCI 标准)第三方来管理您的卡数据。如果您自己实施,那么我建议您尽早寻求 QSA(PCI 合格安全评估员)的帮助来评估您计划实施的安全性。最终,您需要说服 QSA 才能通过 PCI 要求,他们会非常乐意提供建议。

This will not be PCI compliant. Data encrypting keys cannot be stored in plaintext. The specific point is 3.5.2 which is:

Examine system configuration files to
verify that keys are stored in
encrypted format, and that
key-encrypting keys are stored
separately from data-encrypting keys.

You would probably also have other issues around the key management area, such as 3.6.6 (Split knowledge and dual control of keys)

Verify that key-management procedures
are implemented to require split
knowledge and dual control of keys
(for example, requiring two or three
people, each knowing only their own
part of the key, to reconstruct the
whole key).

Key management is the most challenging part of PCI compliance. You may want to consider using a (already PCI compliant) 3rd party to manage your card data. If you are rolling your own then I would advise that you bring in the assistance of a QSA (PCI Qualified Security Assesor) at the earliest opportunity to evaluate the security you're planning on implementing. ultimately it will be the QSA that you need to convince in order to pass your PCI requirements, and they will be more than happy to advise.

想挽留 2024-09-17 15:18:31

您需要将对称密钥存储在某处。配置文件是一个好地方,只要没有人可以访问它。

You need to store the symmetric key somewhere. A configuration file is a good place, as long as no one has access to it.

独夜无伴 2024-09-17 15:18:31

我有一个想法,

您可以使用 keystore.jks 的 keyPair 加密所有纯密码。您知道 keystore.jks 有自己的密码。您可以记住该密码,并在程序启动时在控制台上输入该密码。例如,当您的程序启动时:

Console console = System.console();
        keyPair = loadKeystore(new String(console.readPassword()));


private static KeyPair loadKeystore(String pwd) {
        InputStream is = Main.class.getResourceAsStream("/keystore.jks");

        KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
        keystore.load(is, s.toCharArray());

        String alias = "youralias";

        Key key = keystore.getKey(alias, pwd.toCharArray());
        if (key instanceof PrivateKey) {
            // Get certificate of public key
            Certificate cert = keystore.getCertificate(alias);

            // Get public key
            PublicKey publicKey = cert.getPublicKey();

            // Return a key pair
            return new KeyPair(publicKey, (PrivateKey) key);
        }
        return null;
    }

当您返回密钥对时,您可以使用它来加密您的密码。

key = loadKeystore("yourpass").getPrivate().getEncoded()

好运

I have an idea

you can encrypt all of your plain password with keyPair of keystore.jks. You know that the keystore.jks has its own password. you can remember that password and when your program get started enter it on console. for example when your program start:

Console console = System.console();
        keyPair = loadKeystore(new String(console.readPassword()));


private static KeyPair loadKeystore(String pwd) {
        InputStream is = Main.class.getResourceAsStream("/keystore.jks");

        KeyStore keystore = KeyStore.getInstance(KeyStore.getDefaultType());
        keystore.load(is, s.toCharArray());

        String alias = "youralias";

        Key key = keystore.getKey(alias, pwd.toCharArray());
        if (key instanceof PrivateKey) {
            // Get certificate of public key
            Certificate cert = keystore.getCertificate(alias);

            // Get public key
            PublicKey publicKey = cert.getPublicKey();

            // Return a key pair
            return new KeyPair(publicKey, (PrivateKey) key);
        }
        return null;
    }

when you return the keypair you can uses it for encrypt your password.

key = loadKeystore("yourpass").getPrivate().getEncoded()

goodluck

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文