Skip to content

Commit 9bd5e21

Browse files
committed
Only set insecure socket factory on current connection (#678)
1 parent 854c863 commit 9bd5e21

File tree

4 files changed

+19
-13
lines changed

4 files changed

+19
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
# CheckStyle-IDEA Changelog
33

4+
* **5.113.1** Fixed: Insecure socket factory is now only set for the current connection (#678).
45
* **5.113.0** New: Added Checkstyle 12.0.1.
56
* **5.112.0** Fixed: Keep focus in tool window when scrolling result, matching find results behaviour (#676).
67
* **5.112.0** Removed: Removed update notification, as IDEA now notifies when plugins are updated.

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ plugins {
1919
id("org.infernus.idea.checkstyle.build")
2020
}
2121

22-
version = "5.113.0"
22+
version = "5.113.1"
2323

2424
intellijPlatform {
2525
pluginConfiguration {

src/main/java/org/infernus/idea/checkstyle/model/InsecureHTTPURLConfigurationLocation.java

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
import javax.net.ssl.TrustManager;
99
import javax.net.ssl.X509TrustManager;
1010
import java.io.IOException;
11-
import java.io.InputStream;
11+
import java.net.URLConnection;
12+
import java.security.KeyManagementException;
13+
import java.security.NoSuchAlgorithmException;
1214
import java.security.cert.X509Certificate;
1315

1416
/**
@@ -22,20 +24,22 @@ public InsecureHTTPURLConfigurationLocation(@NotNull final Project project,
2224
super(id, ConfigurationType.INSECURE_HTTP_URL, project);
2325
}
2426

25-
@NotNull
2627
@Override
27-
protected InputStream resolveFile(@NotNull final ClassLoader checkstyleClassLoader) throws IOException {
28-
TrustManager[] trustAllCerts = new TrustManager[]{new AllTrustingTrustManager()};
29-
30-
try {
31-
final SSLContext sc = SSLContext.getInstance("TLSv1.3");
32-
sc.init(null, trustAllCerts, new java.security.SecureRandom());
33-
HttpsURLConnection.setDefaultSSLSocketFactory(sc.getSocketFactory());
34-
} catch (Exception ignored) {
35-
// we care not for security
28+
@NotNull URLConnection connectionTo(final String location) throws IOException {
29+
final URLConnection urlConnection = super.connectionTo(location);
30+
31+
if (urlConnection instanceof HttpsURLConnection httpsURLConnection) {
32+
try {
33+
final TrustManager[] trustAllCerts = new TrustManager[]{new AllTrustingTrustManager()};
34+
final SSLContext sc = SSLContext.getInstance("TLSv1.3");
35+
sc.init(null, trustAllCerts, new java.security.SecureRandom());
36+
httpsURLConnection.setSSLSocketFactory(sc.getSocketFactory());
37+
} catch (NoSuchAlgorithmException | KeyManagementException e) {
38+
throw new IOException("Failed to set an insecure SSL socket factory", e);
39+
}
3640
}
3741

38-
return super.resolveFile(checkstyleClassLoader);
42+
return urlConnection;
3943
}
4044

4145
private static final class AllTrustingTrustManager implements X509TrustManager {

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<change-notes>
2626
<![CDATA[
2727
<ul>
28+
<li>5.113.1: Fixed: Insecure socket factory is now only set for the current connection (#678).</li>
2829
<li>5.113.0: New: Added Checkstyle 12.0.1.</li>
2930
<li>5.112.0: Fixed: Keep focus in tool window when scrolling result, matching find results behaviour (#676).</li>
3031
<li>5.112.0: Removed: Removed update notification, as IDEA now notifies when plugins are updated.</li>

0 commit comments

Comments
 (0)