From: Takuya Ono Date: Sat, 7 May 2011 19:31:48 +0000 (+0900) Subject: MOD: Use default cacerts KeyStore file. X-Git-Url: http://git.osdn.net/view?p=mdc%2FBetaProject.git;a=commitdiff_plain;h=f54e0948a532801919c197b09af167b9af0148c1 MOD: Use default cacerts KeyStore file. --- diff --git a/deploy/mdc.zip b/deploy/mdc.zip index 525b6a1..66aa548 100644 Binary files a/deploy/mdc.zip and b/deploy/mdc.zip differ diff --git a/src/org/jent/checksmtp/ssl/RespondingX509TrustManager.java b/src/org/jent/checksmtp/ssl/RespondingX509TrustManager.java index 1b19c3f..8858b64 100644 --- a/src/org/jent/checksmtp/ssl/RespondingX509TrustManager.java +++ b/src/org/jent/checksmtp/ssl/RespondingX509TrustManager.java @@ -30,60 +30,10 @@ public class RespondingX509TrustManager implements 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"); - tmf.init(ks); + tmf.init((KeyStore)null); //Default KeyStore by null argument. TrustManager tms[] = tmf.getTrustManagers();