소스 검색

Merge pull request #90 from greboid/dev

Create a TrustingTrustManager instead of an AIC.
pull/92/head
Chris Smith 9 년 전
부모
커밋
1c04ab214c
2개의 변경된 파일48개의 추가작업 그리고 18개의 파일을 삭제
  1. 1
    18
      irc/src/com/dmdirc/parser/irc/IRCParser.java
  2. 47
    0
      irc/src/com/dmdirc/parser/irc/TrustingTrustManager.java

+ 1
- 18
irc/src/com/dmdirc/parser/irc/IRCParser.java 파일 보기

@@ -58,7 +58,6 @@ import java.net.UnknownHostException;
58 58
 import java.security.KeyManagementException;
59 59
 import java.security.NoSuchAlgorithmException;
60 60
 import java.security.SecureRandom;
61
-import java.security.cert.X509Certificate;
62 61
 import java.text.ParseException;
63 62
 import java.text.SimpleDateFormat;
64 63
 import java.util.ArrayList;
@@ -80,7 +79,6 @@ import javax.net.ssl.SSLContext;
80 79
 import javax.net.ssl.SSLSocket;
81 80
 import javax.net.ssl.SSLSocketFactory;
82 81
 import javax.net.ssl.TrustManager;
83
-import javax.net.ssl.X509TrustManager;
84 82
 
85 83
 import dagger.ObjectGraph;
86 84
 
@@ -220,22 +218,7 @@ public class IRCParser extends BaseSocketAwareParser implements SecureParser, En
220 218
     /** Used for reading from the server. */
221 219
     private IRCReader in;
222 220
     /** This is the default TrustManager for SSL Sockets, it trusts all ssl certs. */
223
-    private final TrustManager[] trustAllCerts = {
224
-        new X509TrustManager() {
225
-
226
-            @Override
227
-            public X509Certificate[] getAcceptedIssuers() {
228
-                return null;
229
-            }
230
-
231
-            @Override
232
-            public void checkClientTrusted(final X509Certificate[] certs, final String authType) {
233
-            }
234
-
235
-            @Override
236
-            public void checkServerTrusted(final X509Certificate[] certs, final String authType) {
237
-            }
238
-        },};
221
+    private final TrustManager[] trustAllCerts = {new TrustingTrustManager()};
239 222
     /** Should channels automatically request list modes? */
240 223
     private boolean autoListMode = true;
241 224
     /** Should part/quit/kick callbacks be fired before removing the user internally? */

+ 47
- 0
irc/src/com/dmdirc/parser/irc/TrustingTrustManager.java 파일 보기

@@ -0,0 +1,47 @@
1
+/*
2
+ * Copyright (c) 2006-2015 DMDirc Developers
3
+ *
4
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ * of this software and associated documentation files (the "Software"), to deal
6
+ * in the Software without restriction, including without limitation the rights
7
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ * copies of the Software, and to permit persons to whom the Software is
9
+ * furnished to do so, subject to the following conditions:
10
+ *
11
+ * The above copyright notice and this permission notice shall be included in
12
+ * all copies or substantial portions of the Software.
13
+ *
14
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ * SOFTWARE.
21
+ */
22
+
23
+package com.dmdirc.parser.irc;
24
+
25
+import java.security.cert.X509Certificate;
26
+
27
+import javax.net.ssl.TrustManager;
28
+import javax.net.ssl.X509TrustManager;
29
+
30
+/**
31
+ * Implements a {@link TrustManager} that trusts all certificates.
32
+ */
33
+public class TrustingTrustManager implements X509TrustManager {
34
+
35
+    @Override
36
+    public X509Certificate[] getAcceptedIssuers() {
37
+        return new X509Certificate[0];
38
+    }
39
+
40
+    @Override
41
+    public void checkClientTrusted(final X509Certificate[] certs, final String authType) {
42
+    }
43
+
44
+    @Override
45
+    public void checkServerTrusted(final X509Certificate[] certs, final String authType) {
46
+    }
47
+}

Loading…
취소
저장