goto-dev-null / callisto-app

Callisto is a fan-made app for the content produced by Jupiter Broadcasting, a podcast network that delivers a variety of excellent shows with a thriving communtiy built around it.
Other
8 stars 3 forks source link

Add SSL to IRC #22

Open goto-dev-null opened 11 years ago

goto-dev-null commented 11 years ago

I've torn apart JerkLib (the IRC library that Callisto uses) and examined what it uses to connect and it's basic Java objects. That being said I'm not sure if there's support for just checking a box for SSL.

Not super high on the priority unless I get a ton of requests.

goto-dev-null commented 11 years ago

So I tried for about 4 days to get this to work. This is what I discovered, minus a ton of headaches.

Dissecting JerkLib, I found that -inside ConnectionManager- it uses the SocketChannel Java NIO class, which is used to create non-blocking NIO. Because I really didn't want to revamp everything about the way IRC currently works, the ideas to find a class that was essentially "SSLSocketChannel extends SocketChannel". This was not as easy as it sounds.

I found several implementations under various licenses, but many of them did not deal with creating SSLEngine, the class that Sun created to actually deal with SSL. And, to me, documentation on it is lacking or poor, especially for someone who has not dealt with SSL programmatically before. (Comments I've read elsewhere backup this claim.) Really it seemed like the only difficulty was creating the initial handshake, then possibly modifying the read and write methods. This was the idea.

When I was fiddling with it trying to get it work, I think I came close, but then I discovered that not only does the extended class have to work correctly, it has to be able to work in the Selector class. Now in order to work with this Selector class, it has to implement the FileDescriptorChannel class, which is a private class with one function. Yup, so you cannot use any custom class with a Selector because you cannot implement that interface. Instead you have to re-write the entire Selector.

I looked around and found a few implementations, many of which had dependencies of entire libraries of its target application. Anyway, along with it you also have to create implementations of things like SelectionKey, which is really annoying, but not a big deal. When I finally found one that I thought I could use (which was waaaay over my head at this point), I found that it was using functions that were a part of Libcore and IoBridge, which are -you guessed it- private classes. A part of the Android OS, I believe.

So basically my idea for adding SSL was to create an extended class, drop it in, and have everything work exactly as before. Instead, I'd have to find create a new Selector class with a ton of functions that I have no idea what they do, then both of those new classes would have to work correctly for me to troubleshoot.

In short, it's out of my league. Way. SSL for IRC will be put on hiatus until I learn more about Java, SSL, or both, or someone comes along who knows about them.