在JVM启动argumnets中隐藏纯文本密码."ps -ef |grep'javax.net.ssl.keyStorePassword'“ [英] Hiding plain text password in JVM startup argumnets. " ps -ef | grep 'javax.net.ssl.keyStorePassword'"

查看:57
本文介绍了在JVM启动argumnets中隐藏纯文本密码."ps -ef |grep'javax.net.ssl.keyStorePassword'“的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring Boot应用程序的启动参数具有信任和密钥库详细信息,并带有纯文本密码.

The spring boot application's startup arguments having the trust and keystore details with plain text password.

现在,我想从进程中隐藏以下纯文本密码详细信息:

Now I want to hide this plain text password details from process:

ps -ef | grep 'javax.net.ssl.keyStorePassword'

我创建了具有以下详细信息的其他属性文件.如何在启动参数中添加此属性文件?

I have created different properties file with below details. How we can add this properties file in startup arguments?

javax.net.ssl.keyStore
javax.net.ssl.keyStorePassword
javax.net.ssl.keyStoreType
javax.net.ssl.trustStore
javax.net.ssl.trustStorePassword
javax.net.ssl.trustStoreType

推荐答案

可以使用代理代码将非常简单.

StartupProps.java

import java.io.*;

public class StartupProps {

    public static void premain(String fileName) throws IOException {
        try (FileReader reader = new FileReader(fileName)) {
            System.getProperties().load(reader);
        }
    }
}

该代理还需要一个清单文件:

The agent also requires a manifest file:

MANIFEST.MF

Premain-Class: StartupProps

现在需要使用以下命令将代理与清单一起编译并打包到.jar中:

Now the agent needs to be compiled and packed into a .jar together with the manifest with the following command:

jar cvfm startupprops.jar MANIFEST.MF StartupProps.class

现在,您可以使用代理启动Java应用程序,并指定初始属性文件:

Now you can start your Java application with an agent, specifying the initial properties file:

java -javaagent:startupprops.jar=/path/to/initial.properties <args>

为方便起见,我附上了预先构建的 startupprops.jar

For your convenience, I've attached the prebuilt startupprops.jar

这篇关于在JVM启动argumnets中隐藏纯文本密码.&quot;ps -ef |grep'javax.net.ssl.keyStorePassword'“的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆