Browse Source

Hooray SSL!

Douglas William Thrift 13 years ago
parent
commit
0f5e5399ee
2 changed files with 14 additions and 4 deletions
  1. BIN
      lib/bcprov-jdk16-146.jar
  2. 14 4
      src/net/douglasthrift/bigscreenbot/BigScreenBot.java

BIN
lib/bcprov-jdk16-146.jar


+ 14 - 4
src/net/douglasthrift/bigscreenbot/BigScreenBot.java

@@ -40,8 +40,11 @@ import java.util.Set;
 
 import java.util.regex.Pattern;
 
+import javax.net.ssl.KeyManager;
 import javax.net.ssl.SSLSocketFactory;
 
+import com.google.polo.ssl.DummySSLSocketFactory;
+
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.GnuParser;
 import org.apache.commons.cli.HelpFormatter;
@@ -140,10 +143,17 @@ public class BigScreenBot extends Bot
         setVersion(String.format("Big Screen Bot (%1$s)", System.getProperty("os.name")));
 
         if (settings.getBooleanProperty("ssl", false))
-        {
-            // TODO: figure out how to make this work with Jay's certificate
-            setSocketFactory(SSLSocketFactory.getDefault());
-        }
+            if (settings.getBooleanProperty("verify", true))
+                setSocketFactory(SSLSocketFactory.getDefault());
+            else
+                try
+                {
+                    setSocketFactory(DummySSLSocketFactory.fromKeyManagers(new KeyManager[] {}));
+                }
+                catch (GeneralSecurityException exception)
+                {
+                    error(exception, 1);
+                }
 
         setLogin(System.getProperty("user.name"));
         setName(settings.getProperty("nick", "bigscreenbot"));