diff --git a/src/freenet/clients/fcp/LoadPlugin.java b/src/freenet/clients/fcp/LoadPlugin.java index 3473e76202..6a6c55da6f 100644 --- a/src/freenet/clients/fcp/LoadPlugin.java +++ b/src/freenet/clients/fcp/LoadPlugin.java @@ -29,8 +29,6 @@ public class LoadPlugin extends FCPMessage { private final String pluginURL; private final String urlType; private final boolean store; - private final boolean force; - private final boolean forceHTTPS; public LoadPlugin(SimpleFieldSet fs) throws MessageInvalidException { identifier = fs.get("Identifier"); @@ -51,21 +49,6 @@ public LoadPlugin(SimpleFieldSet fs) throws MessageInvalidException { TYPENAME_URL.equalsIgnoreCase(urlType))) throw new MessageInvalidException(ProtocolErrorMessage.INVALID_FIELD, "Unknown URL type: '"+urlType+"'", identifier, false); } - String officialSource = fs.get("OfficialSource"); - if(officialSource != null) { - if(officialSource.equalsIgnoreCase("https")) { - force = true; - forceHTTPS = true; - } else if(officialSource.equalsIgnoreCase("freenet")) { - force = true; - forceHTTPS = false; - } else { - throw new MessageInvalidException(ProtocolErrorMessage.INVALID_FIELD, "Unknown OfficialSource '"+officialSource+"'", identifier, false); - } - } else { - force = false; - forceHTTPS = false; - } store = fs.getBoolean("Store", false); } @@ -124,7 +107,7 @@ public void run() { } PluginInfoWrapper pi; if (TYPENAME_OFFICIAL.equals(type)) { - pi = node.pluginManager.startPluginOfficial(pluginURL, store, force, forceHTTPS); + pi = node.pluginManager.startPluginOfficial(pluginURL, store); } else if (TYPENAME_FILE.equals(type)) { pi = node.pluginManager.startPluginFile(pluginURL, store); } else if (TYPENAME_FREENET.equals(type)) { diff --git a/src/freenet/clients/http/PproxyToadlet.java b/src/freenet/clients/http/PproxyToadlet.java index 12965a14b5..65008f84d8 100644 --- a/src/freenet/clients/http/PproxyToadlet.java +++ b/src/freenet/clients/http/PproxyToadlet.java @@ -134,12 +134,11 @@ public void handleMethodPOST(URI uri, final HTTPRequest request, ToadletContext if (request.isPartSet("submit-official")) { final String pluginName = request.getPartAsStringFailsafe("plugin-name", 40); - final String pluginSource = request.getPartAsStringFailsafe("pluginSource", 10); - + node.executor.execute(new Runnable() { @Override public void run() { - pm.startPluginOfficial(pluginName, true, true, "https".equals(pluginSource)); + pm.startPluginOfficial(pluginName, true); } }); diff --git a/src/freenet/clients/http/staticfiles/globalsign.pem b/src/freenet/clients/http/staticfiles/globalsign.pem deleted file mode 100644 index f4ce4ca43d..0000000000 --- a/src/freenet/clients/http/staticfiles/globalsign.pem +++ /dev/null @@ -1,21 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDdTCCAl2gAwIBAgILBAAAAAABFUtaw5QwDQYJKoZIhvcNAQEFBQAwVzELMAkG -A1UEBhMCQkUxGTAXBgNVBAoTEEdsb2JhbFNpZ24gbnYtc2ExEDAOBgNVBAsTB1Jv -b3QgQ0ExGzAZBgNVBAMTEkdsb2JhbFNpZ24gUm9vdCBDQTAeFw05ODA5MDExMjAw -MDBaFw0yODAxMjgxMjAwMDBaMFcxCzAJBgNVBAYTAkJFMRkwFwYDVQQKExBHbG9i -YWxTaWduIG52LXNhMRAwDgYDVQQLEwdSb290IENBMRswGQYDVQQDExJHbG9iYWxT -aWduIFJvb3QgQ0EwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDaDuaZ -jc6j40+Kfvvxi4Mla+pIH/EqsLmVEQS98GPR4mdmzxzdzxtIK+6NiY6arymAZavp -xy0Sy6scTHAHoT0KMM0VjU/43dSMUBUc71DuxC73/OlS8pF94G3VNTCOXkNz8kHp -1Wrjsok6Vjk4bwY8iGlbKk3Fp1S4bInMm/k8yuX9ifUSPJJ4ltbcdG6TRGHRjcdG -snUOhugZitVtbNV4FpWi6cgKOOvyJBNPc1STE4U6G7weNLWLBYy5d4ux2x8gkasJ -U26Qzns3dLlwR5EiUWMWea6xrkEmCMgZK9FGqkjWZCrXgzT/LCrBbBlDSgeF59N8 -9iFo7+ryUp9/k5DPAgMBAAGjQjBAMA4GA1UdDwEB/wQEAwIBBjAPBgNVHRMBAf8E -BTADAQH/MB0GA1UdDgQWBBRge2YaRQ2XyolQL30EzTSo//z9SzANBgkqhkiG9w0B -AQUFAAOCAQEA1nPnfE920I2/7LqivjTFKDK1fPxsnCwrvQmeU79rXqoRSLblCKOz -yj1hTdNGCbM+w6DjY1Ub8rrvrTnhQ7k4o+YviiY776BQVvnGCv04zcQLcFGUl5gE -38NflNUVyRRBnMRddWQVDf9VMOyGj/8N7yy5Y0b2qvzfvGn9LhJIZJrglfCm7ymP -AbEVtQwdpf5pLGkkeB6zpxxxYu7KyJesF12KwvhHhm4qxFYxldBniYUr+WymXUad -DKqC5JlR3XC321Y9YeRq4VzW9v493kHMB65jUr9TU/Qr6cf9tveCX4XSQRjbgbME -HMUfpIBvFSDJ3gyICh3WZlXi/EjJKSZp4A== ------END CERTIFICATE----- diff --git a/src/freenet/clients/http/wizardsteps/MISC.java b/src/freenet/clients/http/wizardsteps/MISC.java index 3c33da0f09..d297fcac80 100644 --- a/src/freenet/clients/http/wizardsteps/MISC.java +++ b/src/freenet/clients/http/wizardsteps/MISC.java @@ -99,7 +99,7 @@ public void setUPnP(final boolean enableUPnP) { @Override public void run() { if(enable) { - core.node.pluginManager.startPluginOfficial("UPnP", true, false, false); + core.node.pluginManager.startPluginOfficial("UPnP", true); } else { core.node.pluginManager.killPluginByClass("plugins.UPnP.UPnP", 5000); } diff --git a/src/freenet/node/Node.java b/src/freenet/node/Node.java index ff707988a5..3c34ca8376 100644 --- a/src/freenet/node/Node.java +++ b/src/freenet/node/Node.java @@ -99,7 +99,6 @@ import freenet.node.stats.StoreCallbackStats; import freenet.node.updater.NodeUpdateManager; import freenet.pluginmanager.ForwardPort; -import freenet.pluginmanager.PluginDownLoaderOfficialHTTPS; import freenet.pluginmanager.PluginManager; import freenet.store.BlockMetadata; import freenet.store.CHKStore; @@ -956,7 +955,6 @@ public NodeStarter getNodeStarter(){ this.shutdownHook = SemiOrderedShutdownHook.get(); // Easy stuff String tmp = "Initializing Node using Freenet Build #"+Version.buildNumber()+" r"+Version.cvsRevision()+" and freenet-ext Build #"+NodeStarter.extBuildNumber+" r"+NodeStarter.extRevisionNumber+" with "+System.getProperty("java.vendor")+" JVM version "+System.getProperty("java.version")+" running on "+System.getProperty("os.arch")+' '+System.getProperty("os.name")+' '+System.getProperty("os.version"); - fixCertsFiles(); Logger.normal(this, tmp); System.out.println(tmp); collector = new IOStatisticCollector(); @@ -2709,42 +2707,6 @@ private void deleteOldBDBIndexStoreFiles() { } } - private void fixCertsFiles() { - // Hack to update certificates file to fix update.cmd - // startssl.pem: Might be useful for old versions of update.sh too? - File certs = new File(PluginDownLoaderOfficialHTTPS.certfileOld); - fixCertsFile(certs); - if(FileUtil.detectedOS.isWindows) { - // updater\startssl.pem: Needed for Windows update.cmd. - certs = new File("updater", PluginDownLoaderOfficialHTTPS.certfileOld); - fixCertsFile(certs); - } - } - - private void fixCertsFile(File certs) { - long oldLength = certs.exists() ? certs.length() : -1; - try { - File tmpFile = File.createTempFile(PluginDownLoaderOfficialHTTPS.certfileOld, ".tmp", new File(".")); - PluginDownLoaderOfficialHTTPS.writeCertsTo(tmpFile); - if(FileUtil.renameTo(tmpFile, certs)) { - long newLength = certs.length(); - if(newLength != oldLength) - System.err.println("Updated "+certs+" so that update scripts will work"); - } else { - if(certs.length() != tmpFile.length()) { - System.err.println("Cannot update "+certs+" : last-resort update scripts (in particular update.cmd on Windows) may not work"); - File manual = new File(PluginDownLoaderOfficialHTTPS.certfileOld+".new"); - manual.delete(); - if(tmpFile.renameTo(manual)) - System.err.println("Please delete "+certs+" and rename "+manual+" over it"); - else - tmpFile.delete(); - } - } - } catch (IOException e) { - } - } - /** ** Sets up a program directory using the config value defined by the given ** parameters. diff --git a/src/freenet/node/TextModeClientInterface.java b/src/freenet/node/TextModeClientInterface.java index 004cb523f4..3e11df6524 100644 --- a/src/freenet/node/TextModeClientInterface.java +++ b/src/freenet/node/TextModeClientInterface.java @@ -936,7 +936,7 @@ else if(uline.startsWith("PUTSSKDIR:")) { } else if(uline.startsWith("PLUGLOAD")) { if(uline.startsWith("PLUGLOAD:O:")) { String name = line.substring("PLUGLOAD:O:".length()).trim(); - n.pluginManager.startPluginOfficial(name, true, false, false); + n.pluginManager.startPluginOfficial(name, true); } else if(uline.startsWith("PLUGLOAD:F:")) { String name = line.substring("PLUGLOAD:F:".length()).trim(); n.pluginManager.startPluginFile(name, true); diff --git a/src/freenet/pluginmanager/PluginDownLoaderOfficialHTTPS.java b/src/freenet/pluginmanager/PluginDownLoaderOfficialHTTPS.java deleted file mode 100644 index 6b9f7cc469..0000000000 --- a/src/freenet/pluginmanager/PluginDownLoaderOfficialHTTPS.java +++ /dev/null @@ -1,180 +0,0 @@ -/* This code is part of Freenet. It is distributed under the GNU General - * Public License, version 2 (or at your option any later version). See - * http://www.gnu.org/ for further details of the GPL. */ -package freenet.pluginmanager; - -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.security.KeyStore; -import java.security.cert.Certificate; -import java.security.cert.CertificateFactory; -import java.util.Collection; -import java.util.Iterator; - -import freenet.pluginmanager.PluginManager.PluginProgress; -import freenet.support.api.Bucket; -import freenet.support.io.ArrayBucket; -import freenet.support.io.Closer; -import freenet.support.io.FileBucket; -import freenet.support.io.FileUtil; - -public class PluginDownLoaderOfficialHTTPS extends PluginDownLoaderURL { - private static final String certurlNew = "freenet/clients/http/staticfiles/globalsign.pem"; - private static final String[] certURLs = new String[] { certurlNew }; - public static final String certfileOld = "startssl.pem"; - private static final String certfile = "sslcerts.pem"; - - @Override - public URL checkSource(String source) throws PluginNotFoundException { - return super.checkSource("https://downloads.freenetproject.org/latest/" + - source + ".jar"); - } - - @Override - String getPluginName(String source) throws PluginNotFoundException { - return source + ".jar"; - } - - @Override - String getSHA1sum() throws PluginNotFoundException { - try { - URL sha1url = new URL(getSource().toString()+".sha1"); - URLConnection urlConnection = sha1url.openConnection(); - urlConnection.setUseCaches(false); - urlConnection.setAllowUserInteraction(false); - - InputStream is = openConnectionCheckRedirects(urlConnection); - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - byte[] buffer = new byte[1024]; - int read; - - while ((read = is.read(buffer)) != -1) { - bos.write(buffer, 0, read); - } - - return new String(bos.toByteArray(), "ISO-8859-1").split(" ")[0]; - - } catch (MalformedURLException e) { - throw new PluginNotFoundException("impossible: "+e,e); - } catch (IOException e) { - throw new PluginNotFoundException("Error while fetching sha1 for plugin: "+e,e); - } - } - - @Override - InputStream getInputStream(PluginProgress progress) throws IOException { - File TMP_KEYSTORE = null; - FileInputStream fis = null; - InputStream is = null; - try { - TMP_KEYSTORE = File.createTempFile("keystore", ".tmp"); - TMP_KEYSTORE.deleteOnExit(); - - KeyStore ks = KeyStore.getInstance("JKS"); - ks.load(null, new char[0]); - - is = getCert(); - - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - Collection c = cf.generateCertificates(is); - Iterator it = c.iterator(); - while(it.hasNext()) { - Certificate cert = it.next(); - ks.setCertificateEntry(cert.getPublicKey().toString(), cert); - } - FileOutputStream tmpFOS = new FileOutputStream(TMP_KEYSTORE); - try { - ks.store(tmpFOS, new char[0]); - } finally { - Closer.close(tmpFOS); - } - System.out.println("The CA has been imported into the trustStore"); - } catch(Exception e) { - System.err.println("Error while handling the CA :" + e.getMessage()); - throw new IOException("Error while handling the CA : "+e); - } finally { - Closer.close(fis); - } - - System.setProperty("javax.net.ssl.trustStore", TMP_KEYSTORE.toString()); - - return super.getInputStream(progress); - } - - private InputStream getCert() throws IOException { - - // normal the file should be here, - // left by installer or update script - File certFile = new File(certfile).getAbsoluteFile(); - - if (certFile.exists()) { - return new FileInputStream(certFile); - } - - Bucket bucket; - OutputStream os = null; - - try { - try { - bucket = new FileBucket(certFile, false, false, false, false); - os = bucket.getOutputStream(); - writeCerts(os); - // If this fails, we need the whole fetch to fail. - os.close(); os = null; - } finally { - Closer.close(os); - } - return bucket.getInputStream(); - } catch (IOException e) { - // We don't have access to TempBucketFactory here. - // But the certs should be small, so just keep them in memory. - bucket = new ArrayBucket(); - os = bucket.getOutputStream(); - writeCerts(os); - os.close(); - return bucket.getInputStream(); - } - } - - private static void writeCerts(OutputStream os) throws IOException { - // try to create pem file - ClassLoader loader = ClassLoader.getSystemClassLoader(); - InputStream in = null; - for(String certurl : certURLs) { - try { - in = loader.getResourceAsStream(certurl); - if (in != null) { - FileUtil.copy(in, os, -1); - } else { - throw new IOException("Could not find certificates in fred source nor find certificates file"); - } - } finally { - if (in != null) { - in.close(); - } - } - } - } - - /** For the benefit mainly of the Windows updater script. - * It uses startssl.pem */ - public static void writeCertsTo(File file) throws IOException { - FileOutputStream fos = new FileOutputStream(file); - writeCerts(fos); - fos.close(); - } - - public boolean isOfficialPluginLoader() { - return true; - } - -} diff --git a/src/freenet/pluginmanager/PluginManager.java b/src/freenet/pluginmanager/PluginManager.java index 09ba6132b7..1221b7687f 100644 --- a/src/freenet/pluginmanager/PluginManager.java +++ b/src/freenet/pluginmanager/PluginManager.java @@ -298,7 +298,7 @@ public PluginInfoWrapper startPluginAuto(final String pluginname, boolean store) OfficialPluginDescription desc; if((desc = isOfficialPlugin(pluginname)) != null) { - return startPluginOfficial(pluginname, store, desc, false, false); + return startPluginOfficial(pluginname, store, desc); } try { @@ -318,18 +318,13 @@ public PluginInfoWrapper startPluginAuto(final String pluginname, boolean store) return startPluginURL(pluginname, store); } - public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean store, boolean force, boolean forceHTTPS) { - return startPluginOfficial(pluginname, store, officialPlugins.get(pluginname), force, forceHTTPS); + public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean store) { + return startPluginOfficial(pluginname, store, officialPlugins.get(pluginname)); } - public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean store, OfficialPluginDescription desc, boolean force, boolean forceHTTPS) { - if((alwaysLoadOfficialPluginsFromCentralServer && !force)|| force && forceHTTPS) { - return realStartPlugin(new PluginDownLoaderOfficialHTTPS(), pluginname, store, - desc.alwaysFetchLatestVersion); - } else { - return realStartPlugin(new PluginDownLoaderOfficialFreenet(client, node, false), - pluginname, store, desc.alwaysFetchLatestVersion); - } + public PluginInfoWrapper startPluginOfficial(final String pluginname, boolean store, OfficialPluginDescription desc) { + return realStartPlugin(new PluginDownLoaderOfficialFreenet(client, node, false), + pluginname, store, desc.alwaysFetchLatestVersion); } public PluginInfoWrapper startPluginFile(final String filename, boolean store) {