|
View:
New views
4 Messages
—
Rating Filter:
Alert me
|
|
|
Problem with JavaMail 1.4, SSLSocketFactory, and Web StartHi.
So I'm trying to move up to JavaMail 1.4 for my application, and am running into a bit of a snag. I have a custom SSLSocketFactory and TrustManager set up so that users can manually accept untrusted certificates in a web browser-like fashion--that is, if an SSL certificate is untrusted, you get a pop-up displaying the information on the certificate and an option to trust that certificate. Now, the new way to do this in JavaMail 1.4 is to set up your SSLSocketFactory as the default SSLSocketFactory, like so: java.security.Security.setProperty("ssl.SocketFactory.provider", "net.suberic.pooka.ssl.PookaSSLSocketFactory"); So far so good. This works just fine when I'm running as an everyday J2SE application. When I try to deploy under Web Start, though, I end up getting this error: javax.mail.MessagingException: java.lang.ClassNotFoundException: net.suberic.pooka.ssl.PookaSSLSocketFactory; nested exception is: java.net.SocketException: java.lang.ClassNotFoundException: net.suberic.pooka.ssl.PookaSSLSocketFactory (full stack trace included at the bottom) Of course, net.suberic.pooka.ssl.PookaSSLSocketFactory _is_ included in the jar files available through Web Start. Assumingly what's happening here is a classloader problem; I'm guessing that javax.net.ssl.SSLSocketFactory is getting loaded on a higher-up classloader such that net.suberic.pooka.ssl.PookaSSLSocketFactory isn't available to it. So... First, I guess, is the question: am I doing anything wrong here, or is this actually broken? Second, is there anything that I can do about this? That I see I have a few options, none of which are all that good. I could keep using the old "mail.imaps.socketFactory.class" settings, which would, I believe, work for imaps connections but not for TLS connections, right? Or I could drop my custom SSLSocketFactory, which would be a big pain for anyone using self-signed certificates. Or I could drop Web Start, which isn't really an option. Or I suppose I could just file a bug (now that I look back at it, probably with either JSSE or Web Start; I think that JavaMail is trying to do the right thing) and see how long it takes to get fixed.... -allen --- full stack trace --- javax.mail.MessagingException: java.lang.ClassNotFoundException: net.suberic.pooka.ssl.PookaSSLSocketFactory; nested exception is: java.net.SocketException: java.lang.ClassNotFoundException: net.suberic.pooka.ssl.PookaSSLSocketFactory at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479) at javax.mail.Service.connect(Service.java:275) at javax.mail.Service.connect(Service.java:156) at javax.mail.Service.connect(Service.java:105) at net.suberic.pooka.StoreInfo.connectStore(StoreInfo.java:762) at net.suberic.pooka.gui.StoreNode$OpenAction.actionPerformed(StoreNode.java:3 05) at net.suberic.util.thread.ActionThread.run(ActionThread.java:82) Caused by: java.net.SocketException: java.lang.ClassNotFoundException: net.suberic.pooka.ssl.PookaSSLSocketFactory at javax.net.ssl.DefaultSSLSocketFactory.throwException(SSLSocketFactory.java: 179) at javax.net.ssl.DefaultSSLSocketFactory.createSocket(SSLSocketFactory.java:18 6) at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:224) at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189) at com.sun.mail.iap.Protocol.<init>(Protocol.java:84) at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:87) at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:446) ... 6 more Caused by: java.lang.ClassNotFoundException: net.suberic.pooka.ssl.PookaSSLSocketFactory at java.net.URLClassLoader$1.run(URLClassLoader.java:200) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:188) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276) at java.lang.ClassLoader.loadClass(ClassLoader.java:251) at javax.net.ssl.SSLSocketFactory.getDefault(SSLSocketFactory.java:85) at net.suberic.pooka.StoreManager.setupSSL(StoreManager.java:248) at net.suberic.pooka.StartupManager.loadManagers(StartupManager.java:463) at net.suberic.pooka.StartupManager.startupPooka(StartupManager.java:85) at net.suberic.pooka.StartupManager.runPooka(StartupManager.java:69) at net.suberic.pooka.Pooka.main(Pooka.java:32) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:3 9) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImp l.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.sun.javaws.Launcher.executeApplication(Launcher.java:1196) at com.sun.javaws.Launcher.executeMainClass(Launcher.java:1142) at com.sun.javaws.Launcher.doLaunchApp(Launcher.java:989) at com.sun.javaws.Launcher.run(Launcher.java:105) at java.lang.Thread.run(Thread.java:619) =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
Re: Problem with JavaMail 1.4, SSLSocketFactory, and Web Startallen petersen wrote:
> Hi. > > So I'm trying to move up to JavaMail 1.4 for my application, and am running > into a bit of a snag. I have a custom SSLSocketFactory and TrustManager > set up so that users can manually accept untrusted certificates in a web > browser-like fashion--that is, if an SSL certificate is untrusted, you get > a pop-up displaying the information on the certificate and an option to > trust that certificate. Now, the new way to do this in JavaMail 1.4 is to > set up your SSLSocketFactory as the default SSLSocketFactory, like so: > > java.security.Security.setProperty("ssl.SocketFactory.provider", > "net.suberic.pooka.ssl.PookaSSLSocketFactory"); > > So far so good. This works just fine when I'm running as an everyday J2SE > application. > > When I try to deploy under Web Start, though, I end up getting this error: > > javax.mail.MessagingException: java.lang.ClassNotFoundException: > net.suberic.pooka.ssl.PookaSSLSocketFactory; > nested exception is: > java.net.SocketException: java.lang.ClassNotFoundException: > net.suberic.pooka.ssl.PookaSSLSocketFactory > > (full stack trace included at the bottom) > > Of course, net.suberic.pooka.ssl.PookaSSLSocketFactory _is_ included in the > jar files available through Web Start. Assumingly what's happening here is > a classloader problem; I'm guessing that javax.net.ssl.SSLSocketFactory is > getting loaded on a higher-up classloader such that > net.suberic.pooka.ssl.PookaSSLSocketFactory isn't available to it. > > So... First, I guess, is the question: am I doing anything wrong here, or > is this actually broken? > > Second, is there anything that I can do about this? That I see I have a > few options, none of which are all that good. I could keep using the old > "mail.imaps.socketFactory.class" settings, which would, I believe, work for > imaps connections but not for TLS connections, right? Or I could drop my > custom SSLSocketFactory, which would be a big pain for anyone using > self-signed certificates. Or I could drop Web Start, which isn't really an > option. > > Or I suppose I could just file a bug (now that I look back at it, probably > with either JSSE or Web Start; I think that JavaMail is trying to do the > right thing) and see how long it takes to get fixed.... I think you're right that this is a class loader issue, possibly a bug in JSSE. I'm trying to find someone in the JSSE group to help with this. I don't know any way to work around this problem, but possibly someone in the Java Web Start forum can help? http://forum.java.sun.com/forum.jspa?forumID=38 =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
Re: Problem with JavaMail 1.4, SSLSocketFactory, and Web StartHere's the response I got from the JSSE team:
This property is also read only once (the first time SSLSocketFactory.getDefault() is called), so it may already have been initialized by Plugin/Webstart by the time the application sets the property. I think that leaves you with... > I could keep using the old > "mail.imaps.socketFactory.class" settings, which would, I believe, work for > imaps connections but not for TLS connections, right? It works for imaps, which can use the SSL or TLS protocols, but it doesn't work for the STARTTLS command that switches a socket from plain to secure. =========================================================================== To unsubscribe, send email to listserv@... and include in the body of the message "signoff JAVAMAIL-INTEREST". For general help, send email to listserv@... and include in the body of the message "help". |
|
|
Re: Problem with JavaMail 1.4, SSLSocketFactory, and Web Start
Wow this is an old thread, but I had the same problem and for the sake of others, I got around this by using reflection. Instead of java.security.Security.setProperty("ssl.SocketFactory.provider","TestSocketFactory"); I used something like: Field field = SSLSocketFactory.class.getDeclaredFields()[0]; field.setAccessible(true); field.set(null, new TestSocketFactory()); This sets the "theFactory" member of SSLSocketFactory, which is used when getDefault() is called. It's not pretty but it worked for me! |
| Free embeddable forum powered by Nabble | Forum Help |