Hi, I committed the attached patch that was discussed (a bit) two weeks ago. The makes sure that SSLSocketFactory.getDefault() and SSLServerSocketFactory.getDefault() always return a factory instance (instead of throwing an error if there is a configuration problem). The factory will now throw the exception (this is specified in the spec, but the exception type isn't, so we may still be incompatible there.)
Regards, Jeroen 2006-12-28 Jeroen Frijters <[EMAIL PROTECTED]> * javax/net/ssl/SSLServerSocketFactory.java: (getDefault): Return inoperative factory instead of throwing error (as per spec). (ErrorServerSocketFactory): New class. * javax/net/ssl/SSLSocketFactory.java: (getDefault): Return inoperative factory instead of throwing error (as per spec). (ErrorSocketFactory): New class.
Index: javax/net/ssl/SSLServerSocketFactory.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/net/ssl/SSLServerSocketFactory.java,v retrieving revision 1.3 diff -u -r1.3 SSLServerSocketFactory.java --- javax/net/ssl/SSLServerSocketFactory.java 2 Jul 2005 20:32:45 -0000 1.3 +++ javax/net/ssl/SSLServerSocketFactory.java 11 Dec 2006 15:16:13 -0000 @@ -38,6 +38,9 @@ package javax.net.ssl; +import java.io.IOException; +import java.net.InetAddress; +import java.net.ServerSocket; import java.security.KeyStore; import java.security.Security; @@ -138,8 +141,9 @@ } catch (Exception ex) { - throw new RuntimeException("error instantiating default server socket factory: " - + ex.toString()); + return new ErrorServerSocketFactory(new RuntimeException( + "error instantiating default server socket factory: " + + ex.toString(), ex)); } } try @@ -149,7 +153,52 @@ catch (Exception e) { } - throw new RuntimeException("no SSLSocketFactory implementation available"); + return new ErrorServerSocketFactory(new RuntimeException( + "no SSLSocketFactory implementation available")); + } + + private static final class ErrorServerSocketFactory + extends SSLServerSocketFactory + { + private RuntimeException x; + + ErrorServerSocketFactory(RuntimeException x) + { + this.x = x; + } + + public ServerSocket createServerSocket() throws IOException + { + throw (IOException) new IOException().initCause(x); + } + + public ServerSocket createServerSocket(int port) throws IOException + { + throw (IOException) new IOException().initCause(x); + } + + public ServerSocket createServerSocket(int port, int backlog) + throws IOException + { + throw (IOException) new IOException().initCause(x); + } + + public ServerSocket createServerSocket(int port, int backlog, + InetAddress ifAddress) + throws IOException + { + throw (IOException) new IOException().initCause(x); + } + + public String[] getDefaultCipherSuites() + { + throw new RuntimeException(x); + } + + public String[] getSupportedCipherSuites() + { + throw new RuntimeException(x); + } } // Abstract methods. Index: javax/net/ssl/SSLSocketFactory.java =================================================================== RCS file: /cvsroot/classpath/classpath/javax/net/ssl/SSLSocketFactory.java,v retrieving revision 1.5 diff -u -r1.5 SSLSocketFactory.java --- javax/net/ssl/SSLSocketFactory.java 11 Dec 2006 13:45:55 -0000 1.5 +++ javax/net/ssl/SSLSocketFactory.java 11 Dec 2006 15:15:27 -0000 @@ -39,6 +39,7 @@ package javax.net.ssl; import java.io.IOException; +import java.net.InetAddress; import java.net.Socket; import java.security.KeyStore; import java.security.Security; @@ -141,8 +142,9 @@ } catch (Exception ex) { - throw new RuntimeException("error instantiating default socket factory: " - + ex.toString(), ex); + return new ErrorSocketFactory(new RuntimeException( + "error instantiating default socket factory: " + ex.toString(), + ex)); } } try @@ -152,7 +154,65 @@ catch (Exception e) { } - throw new RuntimeException("no SSLSocketFactory implementation available"); + return new ErrorSocketFactory(new RuntimeException( + "no SSLSocketFactory implementation available")); + } + + private static final class ErrorSocketFactory extends SSLSocketFactory + { + private RuntimeException x; + + ErrorSocketFactory(RuntimeException x) + { + this.x = x; + } + + public Socket createSocket() throws IOException + { + throw (IOException) new IOException().initCause(x); + } + + public Socket createSocket(String host, int port) + throws IOException + { + throw (IOException) new IOException().initCause(x); + } + + public Socket createSocket(String host, int port, InetAddress localHost, + int localPort) + throws IOException + { + throw (IOException) new IOException().initCause(x); + } + + public Socket createSocket(InetAddress host, int port) throws IOException + { + throw (IOException) new IOException().initCause(x); + } + + public Socket createSocket(InetAddress hast, int port, InetAddress localHost, + int localPort) + throws IOException + { + throw (IOException) new IOException().initCause(x); + } + + public String[] getDefaultCipherSuites() + { + throw new RuntimeException(x); + } + + public String[] getSupportedCipherSuites() + { + throw new RuntimeException(x); + } + + public Socket createSocket(Socket s, String host, int port, + boolean autoClose) + throws IOException + { + throw new RuntimeException(x); + } } // Abstract methods.