OSDN Git Service

MOD: Use default cacerts KeyStore file.
authorTakuya Ono <takuya-o@users.sourceforge.jp>
Sat, 7 May 2011 19:31:48 +0000 (04:31 +0900)
committerTakuya Ono <takuya-o@users.sourceforge.jp>
Sat, 7 May 2011 19:31:48 +0000 (04:31 +0900)
deploy/mdc.zip
src/org/jent/checksmtp/ssl/RespondingX509TrustManager.java

index 525b6a1..66aa548 100644 (file)
Binary files a/deploy/mdc.zip and b/deploy/mdc.zip differ
index 1b19c3f..8858b64 100644 (file)
@@ -30,60 +30,10 @@ public class RespondingX509TrustManager implements X509TrustManager {
 
   public RespondingX509TrustManager() throws Exception {
     // create a "default" JSSE X509TrustManager.
 
   public RespondingX509TrustManager() throws Exception {
     // create a "default" JSSE X509TrustManager.
-    File file = null;
-    FileInputStream cacertsFileInputStream = null;
-    char cacertsPass[] = null;
-
-    //Create&load KeyStore
-    KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
-    //KeyStore ks = KeyStore.getInstance("JKS");
-    //ks.load(new FileInputStream("trustedCerts"), "passphrase".toCharArray());
-    try {
-      //Check file at sytem property javax.net.ssl.trustStore.
-      String cacertsFileName = System.getProperty("javax.net.ssl.trustStore");
-      if (cacertsFileName != null) {
-        file = new File(cacertsFileName);
-        System.out.println("System property javax.net.ssl.trustStore:"
-                + cacertsFileName);
-      }
-      if (file == null) {
-        //Check Default trustStore
-        char SEP = File.separatorChar;
-        String cacertsDirName = System.getProperty("java.home") + SEP + "lib"
-                + SEP + "security";
-        file = new File(cacertsDirName, "jssecacerts");
-        if (!file.canRead()) {
-          System.err.println("NotFound:" + file.getPath());
-          file = new File(cacertsDirName, "cacerts");
-        }
-      }
-      if (!file.canRead()) {
-        System.err.println("NotFound:" + file.getPath());
-        cacertsFileInputStream = null;
-      } else {
-        cacertsFileInputStream = new FileInputStream(file);
-        System.err.println("Load trustStore:" + file.getPath());
-        String cacertsPassString = System.getProperty("javax.net.ssl.trustStorePassword");
-        if (cacertsPassString != null) {
-          cacertsPass = cacertsPassString.toCharArray();
-        }
-      }
-    } catch (NullPointerException npEx) {
-      npEx.printStackTrace(System.out);
-      cacertsFileInputStream = null;
-    } catch (FileNotFoundException fnfEx) {
-      System.err.println("CanNotRead(" + fnfEx + "):" + file.getPath());
-      cacertsFileInputStream = null;
-    } catch (SecurityException ex) {
-      cacertsFileInputStream = null;
-      System.err.println("CanNotRead(" + ex + "):" + file.getPath());
-    }
-    ks.load(cacertsFileInputStream, cacertsPass);
-    cacertsFileInputStream.close();
-
+    //KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType());
     TrustManagerFactory tmf =
             TrustManagerFactory.getInstance("PKIX");
     TrustManagerFactory tmf =
             TrustManagerFactory.getInstance("PKIX");
-    tmf.init(ks);
+    tmf.init((KeyStore)null);  //Default KeyStore by null argument.
 
     TrustManager tms[] = tmf.getTrustManagers();
 
 
     TrustManager tms[] = tmf.getTrustManagers();