简体   繁体   English

具有SSL连接功能的通用JMS客户端

[英]Generic JMS Client with SSL connection capability

Currently, I have implemented a non-SSL secured client using the standard JMS API (only javax.jms.* classes). 当前,我已经使用标准JMS API(仅javax.jms.*类)实现了非SSL安全客户端。 When supplied with specific product JAR and proper classnames, it is able to connect to any JMS server. 当提供特定的产品JAR和正确的类名时,它可以连接到任何JMS服务器。

Is there a way how to implement such generic (vendor-independent) JMS client with SSL connection capabilities? 有没有办法通过SSL连接功能实现这种通用的(独立于供应商的)JMS客户端?

My research was not successful - I've found several examples implementing JMS with SSL (eg Novell JMS , ActiveMQ ) but none of them avoids using the vendor-specific classes directly in code and implementations differ considerably. 我的研究并不成功-我发现了几个使用SSL实现JMS的示例(例如Novell JMSActiveMQ ),但是它们都不能避免直接在代码中使用特定于供应商的类,并且实现方式也大不相同。

Using SSL doesn't require any code change in client. 使用SSL不需要在客户端中更改任何代码。 Adding SSL capability is only matter of configuration. 添加SSL功能仅是配置问题。

In general, there are few things that will differ: 通常,几乎没有什么不同:

  1. Connection URL so the client connects over SSL protocol to proper port ( ssl://broker_url instead of tcp://broker_url ). 连接URL,以便客户端通过SSL协议连接到正确的端口( ssl://broker_url而不是tcp://broker_url )。
  2. Connection factory class - may be different from non-SSL one. 连接工厂类 -可能与非SSL 不同。
  3. Keystore and/or truststore to be used. 要使用的密钥库和/或信任 Paths to these files may be set programmatically using specific methods – but this approach requires vendor specific code to be implemented. 可以使用特定方法以编程方式设置这些文件的路径-但这种方法需要实施特定于供应商的代码。 Better option is to pass the KS/TS java system properties. 更好的选择是传递KS / TS java系统属性。 (This can be done even without any preparation using the -D JVM option.) (即使没有使用-D JVM选项的任何准备,也可以完成此操作。)

Since points 2. and 3. differ from one JMS broker to another, see your vendor's documentation for further details. 由于第2点和第3点从一个JMS代理到另一个JMS代理,因此有所不同,请参阅供应商的文档以获取更多详细信息。


This answer is based on experience with successful connection to Apache ActiveMQ and Tibco EMS, including mutual certificate authentication. 该答案基于成功连接到Apache ActiveMQ和Tibco EMS(包括相互证书认证)的经验。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM