在同一个 JVM 上设置多个信任库
我有一个在 weblogic 服务器上运行的 Java 应用程序。该应用程序有两个不同的模块,它们使用 SSL 连接到外部 Web 服务 - 假设模块 A 和模块 B。
模块 A - 在 Axis 上构建 - 使用信任库 A Moudle B - 基于 Spring-ws 构建 - 使用信任库 B。
模块 A 已存在。正在引入模块 B。
我需要能够根据正在调用的模块在 JVM 中动态设置信任库。
由于某些限制我没有选择 - 创建自定义密钥管理器。 - 使用一个信任库
我尝试在模块 B 代码库中使用 System.setProperty 来设置信任库。然而,只有当模块 B 首先被调用时它才有效。例如 - 说 我重新启动了 JVM 然后我调用模块 A - 它在 JVM 中设置了自己的信任库 然后我调用模块 B - 它失败了 - 即使我使用了 System.setProperty 方法,它也没有在 JVM 中设置它自己的信任库。
我是否遗漏了某些内容,或者只是 System.setProperty 不会覆盖现有的设置值。如果是这样,我在这里有什么选择。
I have an Java application running on a weblogic server. The application has two distinct modules which use SSL to connect to external web services - let's say module A and module B.
Module A - Built on Axis - Uses truststore A
Moudle B - Built on Spring-ws - Uses truststore B.
Module A is existing. Module B is being introduced.
I need to be able to set the truststore dynamically in the JVM based on which module is being invoked.
Due to some constraints I do not have the option
- to create a custom key manager.
- use one truststore
I tried to use System.setProperty im Module B codebase to set truststore. However it works only if Module B got invoked first. For example - Say
I have a fresh restart of the JVM
then I invoke module A - it set's it's own truststore in the JVM
then I invoke module B - It fails - it's does not set it's own truststore in the JVM even though I have used System.setProperty method.
Am I missing something or it's just that System.setProperty doesn't override existing set values. If so what are my options here.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在运行时动态加载受信任的密钥存储。
请注意,因为
SSLContext.getDefault()
会返回您默认上下文,而您无法修改,因此您必须创建一个新上下文,初始化它,然后将此新上下文设置为默认值。最重要的是,如果您愿意,您可以使用任意数量的信任存储。
You can load trusted key stores dynamically at runtime.
Watch out, because
SSLContext.getDefault()
would give you back the default context which you cannot modify, so you have to create a new one, initialize it then set this new context as the default.The bottom line is that you can use any number of trust stores if you want to.