我有一个使用stomp + ssl连接到tomcat6上的activemq服务器的android客户端。 不幸的是,重用会话时连接会挂起:
ActiveMQ Transport: ssl:///10.0.0.182:56501, WRITE: TLSv1 Handshake, length = 32
[Raw write]: length = 37
0000: 16 03 01 00 20 D7 1D 61 C2 70 38 B6 30 10 33 39 .... ..a.p8.0.39
0010: 7C 4E 1E DC 7E 10 C3 8F 80 E4 51 92 DD CD 10 C9 .N........Q.....
0020: BF 8C B3 B8 8D .....
%% Cached server session: [Session-6, SSL_RSA_WITH_RC4_128_MD5]
我很快就需要一个解决方案,所以我想禁用ssl会话缓存,但我无法做到。
更新:在Android 4.0中它完美运行!那么如何在Android 2.3上安装android 4 jsse提供程序呢?
在客户端我有这段代码:
InputStream clientTruststoreIs = getResources().openRawResource(R.raw.truststore);
KeyStore trustStore = null;
trustStore = KeyStore.getInstance("BKS");
trustStore.load(clientTruststoreIs, "xxxxx".toCharArray());
System.out.println("Loaded server certificates: " + trustStore.size());
TrustManagerFactory tmf = null;
tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
tmf.init(trustStore);
InputStream keyStoreStream = getResources().openRawResource(R.raw.client);
KeyStore keyStore = null;
keyStore = KeyStore.getInstance("BKS");
keyStore.load(keyStoreStream, "xxxxxx".toCharArray());
KeyManagerFactory kmf = null;
kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(keyStore, "xxxxxxxxx".toCharArray());
SSLContext ctx = SSLContext.getInstance("SSL");
ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);
stomp = new Stomp("tcp://" + sp.getString("host", "default.host.it")+ ":"+ sp.getString("port", "61614"));
stomp.setSslContext(ctx);
在服务器上我只有这样的context.xml:
<broker:broker useJmx="true" persistent="false"
brokerName="prato">
<broker:sslContext>
<broker:sslContext keyStore="classpath:keystore.jks" trustStore="classpath:truststore.jks" keyStorePassword="xxxxxx" trustStorePassword="xxxxx"/>
</broker:sslContext>
<broker:transportConnectors>
<broker:transportConnector name="vm" uri="vm://prato" />
<broker:transportConnector name="tcp" uri="tcp://0.0.0.0:${openwire}" />
<broker:transportConnector name="stomp" uri="stomp://0.0.0.0:${stomp}?Trace=true" />
<broker:transportConnector name="stompssl" uri="stomp+ssl://0.0.0.0:${stompssl}?needClientAuth=true" />
</broker:transportConnectors>
</broker:broker>
我该怎么办? 提前感谢您的回复!
马里奥