|
1 Index: org/jivesoftware/smack/XMPPConnection.java |
|
2 =================================================================== |
|
3 --- org/jivesoftware/smack/XMPPConnection.java (révision 11644) |
|
4 +++ org/jivesoftware/smack/XMPPConnection.java (copie de travail) |
|
5 @@ -758,14 +758,14 @@ |
|
6 * @throws Exception if an exception occurs. |
|
7 */ |
|
8 void proceedTLSReceived() throws Exception { |
|
9 - SSLContext context = SSLContext.getInstance("TLS"); |
|
10 + SSLContext context = this.config.getCustomSSLContext(); |
|
11 KeyStore ks = null; |
|
12 KeyManager[] kms = null; |
|
13 PasswordCallback pcb = null; |
|
14 |
|
15 if(config.getCallbackHandler() == null) { |
|
16 ks = null; |
|
17 - } else { |
|
18 + } else if (context == null) { |
|
19 //System.out.println("Keystore type: "+configuration.getKeystoreType()); |
|
20 if(config.getKeystoreType().equals("NONE")) { |
|
21 ks = null; |
|
22 @@ -821,10 +821,12 @@ |
|
23 } |
|
24 |
|
25 // Verify certificate presented by the server |
|
26 - context.init(kms, |
|
27 - new javax.net.ssl.TrustManager[]{new ServerTrustManager(getServiceName(), config)}, |
|
28 - //new javax.net.ssl.TrustManager[]{new OpenTrustManager()}, |
|
29 - new java.security.SecureRandom()); |
|
30 + if (context == null) { |
|
31 + context = SSLContext.getInstance("TLS"); |
|
32 + context.init(kms, |
|
33 + new javax.net.ssl.TrustManager[]{new ServerTrustManager(getServiceName(), config)}, |
|
34 + new java.security.SecureRandom()); |
|
35 + } |
|
36 Socket plain = socket; |
|
37 // Secure the plain connection |
|
38 socket = context.getSocketFactory().createSocket(plain, |
|
39 Index: org/jivesoftware/smack/ConnectionConfiguration.java |
|
40 =================================================================== |
|
41 --- org/jivesoftware/smack/ConnectionConfiguration.java (révision 11644) |
|
42 +++ org/jivesoftware/smack/ConnectionConfiguration.java (copie de travail) |
|
43 @@ -20,6 +20,7 @@ |
|
44 |
|
45 package org.jivesoftware.smack; |
|
46 |
|
47 +import javax.net.ssl.SSLContext; |
|
48 import org.jivesoftware.smack.proxy.ProxyInfo; |
|
49 import org.jivesoftware.smack.util.DNSUtil; |
|
50 |
|
51 @@ -59,6 +60,7 @@ |
|
52 private boolean selfSignedCertificateEnabled = false; |
|
53 private boolean expiredCertificatesCheckEnabled = false; |
|
54 private boolean notMatchingDomainCheckEnabled = false; |
|
55 + private SSLContext customSSLContext; |
|
56 |
|
57 private boolean compressionEnabled = false; |
|
58 |
|
59 @@ -487,6 +489,25 @@ |
|
60 } |
|
61 |
|
62 /** |
|
63 + * Gets the custom SSLContext for SSL sockets. This is null by default. |
|
64 + * |
|
65 + * @return the SSLContext previously set with setCustomSSLContext() or null. |
|
66 + */ |
|
67 + public SSLContext getCustomSSLContext() { |
|
68 + return this.customSSLContext; |
|
69 + } |
|
70 + |
|
71 + /** |
|
72 + * Sets a custom SSLContext for creating SSL sockets. A custom Context causes all other |
|
73 + * SSL/TLS realted settings to be ignored. |
|
74 + * |
|
75 + * @param context the custom SSLContext for new sockets; null to reset default behaviour. |
|
76 + */ |
|
77 + public void setCustomSSLContext(SSLContext context) { |
|
78 + this.customSSLContext = context; |
|
79 + } |
|
80 + |
|
81 + /** |
|
82 * Returns true if the connection is going to use stream compression. Stream compression |
|
83 * will be requested after TLS was established (if TLS was enabled) and only if the server |
|
84 * offered stream compression. With stream compression network traffic can be reduced |