[英]How can my application access the keystore configured in Weblogic admin console?
I would like to access the Identity keystores (JKS) configured in Weblogic's Custom keystore configuration in my web application. 我想访问我的Web应用程序中Weblogic的自定义密钥库配置中配置的Identity密钥库(JKS)。 How can I get weblogic to expose this without relying on the following environment properties: -Djavax.net.ssl.Keystore, -Djavax.net.ssl.KeystorePassword. 如何在不依赖以下环境属性的情况下让weblogic公开它:-Djavax.net.ssl.Keystore,-Djavax.net.ssl.KeystorePassword。
You can use following code as a starting point. 您可以使用以下代码作为起点。
A couple of notes: 几个笔记:
OracleSystemGroup
执行代码的用户需要属于名为OracleSystemGroup
的组 java.lang.String
, which is not recommended. 密钥库密码包含在java.lang.String
,不建议这样做。 Because of these cons I am investigating a better approach. 由于这些缺点,我正在研究一种更好的方法。 I have been trying to find a WebLogic service which would provide services to access certificates and keys in identity store. 我一直在尝试找到一个WebLogic服务,它将提供访问身份存储中的证书和密钥的服务。 It seems that there is not one . 似乎没有一个 。
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());
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.