Skip to content

Commit c89c10f

Browse files
Automatically enabling old TLS and closing connections if the server closed them.
1 parent 54a8321 commit c89c10f

5 files changed

Lines changed: 27 additions & 97 deletions

File tree

src/io/github/explodingbottle/jmagicproxy/DisabledAlgorithmsWarner.java

Lines changed: 0 additions & 84 deletions
This file was deleted.

src/io/github/explodingbottle/jmagicproxy/ProxyMain.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import java.io.File;
2121
import java.io.IOException;
22+
import java.security.Security;
2223

2324
import io.github.explodingbottle.explodingau.ExplodingAULib;
2425
import io.github.explodingbottle.jmagicproxy.api.PluginsManager;
@@ -166,16 +167,10 @@ public static void main(String[] args) {
166167
lgp.openLogStream(new File(logsFolder, logPath));
167168
pluginsManager = new PluginsManager(propsProvider.getAsString(PropertyKey.PROXY_PLUGINS));
168169
pluginsManager.loadPlugins();
169-
if (propsProvider.getAsBoolean(PropertyKey.PROXY_SSL_WARN_ALGORITHMS)) {
170-
DisabledAlgorithmsWarner warner = new DisabledAlgorithmsWarner();
171-
if (warner.mustWarn()) {
172-
mainLogger.log(LoggingLevel.WARN,
173-
"The system has detected that algorithms were present in the jdk.tls.disabledAlgorithms property of java.security. "
174-
+ "This will cause issues with SSL and old algorithms.");
175-
}
176-
}
177170
if (propsProvider.getAsBoolean(PropertyKey.PROXY_SSL_ENABLED)) {
178171
mainLogger.log(LoggingLevel.INFO, "SSL is enabled, proceeding to SSL setup.");
172+
mainLogger.log(LoggingLevel.WARN,
173+
"Please note that every disabled protocols has been enabled again only during the use of this program.");
179174
sslObjectsProvider = new SSLObjectsProvider(
180175
new File(propsProvider.getAsString(PropertyKey.PROXY_SSL_KEYSTORE_PATH)),
181176
propsProvider.getAsString(PropertyKey.PROXY_SSL_KEYSTORE_PASSWORD),
@@ -205,4 +200,8 @@ public static void main(String[] args) {
205200

206201
}
207202

203+
static {
204+
Security.setProperty("jdk.tls.disabledAlgorithms", "");
205+
}
206+
208207
}

src/io/github/explodingbottle/jmagicproxy/properties/PropertyKey.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public enum PropertyKey {
3636
PROXY_SSL_KEYSTORE_PATH("proxy.ssl.keystorepath", "certs/keystore.p12", String.class),
3737
PROXY_SSL_KEYSTORE_PASSWORD("proxy.ssl.keystorepass", "Password", String.class),
3838
PROXY_SSL_KEYSTORE_TYPE("proxy.ssl.keystoretype", "pkcs12", String.class),
39-
PROXY_SSL_WARN_ALGORITHMS("proxy.ssl.warn.algorithms", false, Boolean.class),
4039
PROXY_SSL_SORT_MODE("proxy.ssl.sortmode", "NONE", String.class),
4140
PROXY_SSL_SORT_LIST("proxy.ssl.sortlist", "*", String.class),
4241
WUPROXY_REDIRECT_WUCLIENT("proxy.plugins.wuproxy.redirwuclient", false, Boolean.class),

src/io/github/explodingbottle/jmagicproxy/proxy/ssl/SSLComunicator.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,8 @@ public void startConnection() {
9898
HttpResponse hrqh = new HttpResponse("HTTP/1.1", 200, "Connection Established",
9999
new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER));
100100
output.write((hrqh.toHttpResponseLine() + "\r\n\r\n").getBytes());
101-
inputOutgoing = transferSocket.getInputStream();
102-
outputOutgoing = transferSocket.getOutputStream();
103101
if (transferSocket != null) {
104-
transferPipeOutToIn = new SimpleTransferPipe(inputOutgoing, output);
102+
transferPipeOutToIn = new SimpleTransferPipe(inputOutgoing, output, this);
105103
transferPipeOutToIn.start();
106104
}
107105
logger.log(LoggingLevel.INFO, "Direct connection established.");

src/io/github/explodingbottle/jmagicproxy/proxy/ssl/SimpleTransferPipe.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ class SimpleTransferPipe extends Thread {
4242

4343
private ProxyLogger logger;
4444

45+
private SSLComunicator communicator;
46+
4547
/**
4648
* This is the constructor of the transfer pipe.
4749
*
@@ -55,6 +57,18 @@ public SimpleTransferPipe(InputStream input, OutputStream output) {
5557
logger = ProxyMain.getLoggerProvider().createLogger();
5658
}
5759

60+
/**
61+
* This is the constructor of the transfer pipe.
62+
*
63+
* @param input Represents the input that will feed the output.
64+
* @param output Represents the output that will be feed.
65+
* @param communicator Represents the parent SSL communicator (if any).
66+
*/
67+
public SimpleTransferPipe(InputStream input, OutputStream output, SSLComunicator communicator) {
68+
this(input, output);
69+
this.communicator = communicator;
70+
}
71+
5872
public void run() {
5973
try {
6074
int readedLength = input.read(buffer, 0, buffer.length);
@@ -63,8 +77,12 @@ public void run() {
6377
readedLength = input.read(buffer, 0, buffer.length);
6478
}
6579
} catch (IOException e) {
66-
if (!isInterrupted())
80+
if (!isInterrupted()) {
6781
logger.log(LoggingLevel.WARN, "A tranfer failed for SimpleTransferPipe.", e);
82+
}
83+
}
84+
if (communicator != null) {
85+
communicator.stopCommunicator();
6886
}
6987
}
7088

0 commit comments

Comments
 (0)