从 Oracle JVM (JSSE) 使用 SSL
另见“What TLS cipherspecs/ciphersuites are supported when connecting from Oracle Java (non-IBM JRE) to MQ queue manager?”
在 MQ 客户端版本 8.0.0.2 中包含一个补丁以将 TLS 与 Oracle JVM 一起使用,这适用于上面的 lanes 答案
要让它工作,你需要最新的 MQ 客户端,它包含
IV66840: WMQ V7 JAVA/JMS: 添加对选定 TLS 密码规范的支持
在非 IBM JAVA 运行时环境中运行
http://www-01.ibm.com/support/docview.wss?uid=swg1IV66840
(download)
根据您所在的位置,您可能还需要安装
Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files 8 (download)
要使用它,您必须使用 JVM 参数进行配置:
-Dcom.ibm.mq.cfg.useIBMCipherMappings=false
注意Oracle和IBM JVM之间的默认安全实现行为differs:
Oracle JSSE Reference guide 说:
如果 KeyManager[] 参数为空,那么一个空的 KeyManager 将
为这个上下文定义。
IBM JSSE Reference guide 说:
如果 KeyManager[] 参数为空,则安装的安全
提供者将被搜索最高优先级的实现
KeyManagerFactory,一个合适的 KeyManager 将从那里得到
获得。
这意味着你必须设置your own ssl context
SSLContext sslcontext = SSLContext.getInstance("TLS");
String keyStore = System.getProperty("javax.net.ssl.keyStore");
String keyStoreType = System.getProperty("javax.net.ssl.keyStoreType", KeyStore.getDefaultType());
String keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword","");
KeyManager[] kms = null;
if (keyStore != null)
{
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
KeyStore ks = KeyStore.getInstance(keyStoreType);
if (keyStore != null && !keyStore.equals("NONE")) {
fs = new FileInputStream(keyStore);
ks.load(fs, keyStorePassword.toCharArray());
if (fs != null)
fs.close();
char[] password = null;
if (keyStorePassword.length() > 0)
password = keyStorePassword.toCharArray();
kmf.init(ks,password);
kms = kmf.getKeyManagers();
}
sslcontext.init(kms,null,null);
然后将其提供给 MQ JMS 客户端:
JmsConnectionFactory cf = ...
MQConnectionFactory mqcf = (MQConnectionFactory) cf;
mqcf.setSSLSocketFactory(sslcontext.getSocketFactory());
如果使用应用程序服务器,这可能由您的应用程序服务器处理。