| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
Scott Kovatch wrote:
Well, that suggestion to check the apple keychain worked for me. Thanks! Here is the code I used in case anyone else is interested. Tom private static final String BROWSER_KEYSTORE_PROP_NAME = "deployment.user.security.trusted.certs", JAVA_KEYSTORE_PROP_NAME = "javax.net.ssl.trustStore", JAVA_KEYSTORE_TYPE_PROP_NAME = "javax.net.ssl.trustStoreType", JAVA_KEYSTORE_PROVIDER_PROP_NAME = "javax.net.ssl.trustStoreProvider", APPLE_KEYSTORE_TYPE = "KeychainStore", APPLE_KEYSTORE_PROVIDER = "Apple", APPLE_OS_NAME = "mac os x", TRUSTED_CERT_LOCATION_GUESS = "/Application Data/Sun/Java/Deployment/security/trusted.certs", TRUSTED_CERT_LOCATION_GUESS_SLASH = "/"; private static void activateSSL(){ // If application is running with Java Web Start or as an Applet then this // deployment property may point to the location of the file containing the // user's trusted certificates. String keyStoreName = System.getProperty(BROWSER_KEYSTORE_PROP_NAME,""); boolean usedDeploymentProperty = true; // else we have to guess at the location of the trusted,certs file. // - may only work on Windows under Java 1.5 if (keyStoreName.length() == 0) { usedDeploymentProperty = false; String fileSep = System.getProperty("file.separator","\\"); String userHome = System.getProperty("user.home",""); StringBuffer buf = new StringBuffer(100); buf.append(userHome); buf.append(TRUSTED_CERT_LOCATION_GUESS); int slashPos; while ((slashPos = buf.indexOf(TRUSTED_CERT_LOCATION_GUESS_SLASH)) > -1) { buf.replace(slashPos,slashPos+1,fileSep); } keyStoreName = buf.toString(); } if (new File(keyStoreName).exists()) { System.setProperty(JAVA_KEYSTORE_PROP_NAME, keyStoreName); SchedulingClient.printMessage("Trusted Cert file location set to: " + keyStoreName); } else { String osName = System.getProperty("os.name",""); SchedulingClient.printMessage("OS Name: " + osName); if (osName.equalsIgnoreCase(APPLE_OS_NAME) || osName.startsWith(APPLE_OS_NAME)) { SchedulingClient.printMessage("Detected Apple OS. Using Applet SSL parameters"); System.setProperty(JAVA_KEYSTORE_TYPE_PROP_NAME,APPLE_KEYSTORE_TYPE); System.setProperty(JAVA_KEYSTORE_PROVIDER_PROP_NAME,APPLE_KEYSTORE_PROVIDER); } else { SchedulingClient.printMessage("Warning: Key Store: " + keyStoreName + " does NOT exist"); SchedulingClient.printMessage("Key Store deployment property was " + (usedDeploymentProperty?"not blank":"blank")); } } // setSocketFactory throws an exception from applet in Mozilla Firefox: "factory already defined". // Works in IE 6.0 under Windows XP sp2 and works with Web Start under Windows and Mac OS X try { SchedulingClient.printMessage("Setting RMI Factory"); java.rmi.server.RMISocketFactory.setSocketFactory(new SecureRMISocketFactory()); SchedulingClient.printMessage("SSL initiated"); } catch(Exception e) { SchedulingClient.printMessage("Unable to set socket factory: " + e.getClass().getName() + " " + e.getMessage()); Debug.println(e); // keep going in case we already set the SecureRMISocketFactory within this VM } } |
_______________________________________________ Do not post admin requests to the list. They will be ignored. Java-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/java-dev/email@hidden This email sent to email@hidden
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.