我的应用程序如何访问 Weblogic 管理控制台中配置的密钥库?

2024-02-20

我想访问在我的 Web 应用程序中的 Weblogic 自定义密钥库配置中配置的身份密钥库 (JKS)。如何让 weblogic 在不依赖以下环境属性的情况下公开此内容:-Djavax.net.ssl.Keystore、-Djavax.net.ssl.KeystorePassword。


您可以使用以下代码作为起点。

一些注意事项:

  • 执行代码的用户需要属于一个名为OracleSystemGroup
  • 密钥库是从 EJB 规范不推荐的文件系统加载的。但我认为文件读取是可以安全完成的。
  • 密钥库密码包含在java.lang.String,不建议这样做。

由于这些缺点,我正在研究更好的方法。我一直在尝试找到一个 WebLogic 服务,它可以提供访问身份存储中的证书和密钥的服务。看起来没有一个 http://docs.oracle.com/cd/E21764_01/web.1111/e13710/archtect.htm#i1062666.

InitialContext ic = new InitialContext();
MBeanServer server = (MBeanServer) ic.lookup("java:comp/env/jmx/runtime");

// Get access to server configuration
ObjectName runtime = new ObjectName("com.bea:Name=RuntimeService,Type=weblogic.management.mbeanservers.runtime.RuntimeServiceMBean");
ObjectName serverConfig = (ObjectName) server.getAttribute(runtime, "ServerConfiguration");

/* Load identity store location and passphrase.
 * If e.g. Demo identity has been configured (in WL console) instead of
 * custom identity then the following does not work.
 */

// Passphrase as clear text
Object keyStorePassPhrase = server.getAttribute(serverConfig, "CustomIdentityKeyStorePassPhrase");
Object keyStoreFileName = server.getAttribute(serverConfig, "CustomIdentityKeyStoreFileName");

// Load keystore
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
ks.load(new FileInputStream(keyStoreFileName.toString()),
        keyStorePassPhrase.toCharArray());
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

我的应用程序如何访问 Weblogic 管理控制台中配置的密钥库? 的相关文章

随机推荐