|
25 | 25 | import java.util.ArrayList; |
26 | 26 | import java.util.Collection; |
27 | 27 | import java.util.Collections; |
| 28 | +import java.util.HashSet; |
28 | 29 | import java.util.List; |
29 | | -import java.util.Set; |
30 | 30 |
|
31 | 31 | /** |
32 | 32 | * Builds {@link SSLSocketFactory} and {@link X509ExtendedTrustManager} instances for verifying |
@@ -92,7 +92,7 @@ public static TrustProvider fromDirectory(String certsDirPath) throws IOExceptio |
92 | 92 | return builder.build(); |
93 | 93 | } |
94 | 94 |
|
95 | | - public static TrustProvider fromTrustManager(X509TrustManager trustManager) throws IOException, GeneralSecurityException { |
| 95 | + public static TrustProvider fromTrustManager(X509TrustManager trustManager) throws GeneralSecurityException { |
96 | 96 | SSLContext sslContext = SSLContext.getInstance("TLS"); |
97 | 97 | sslContext.init(new KeyManager[0], new TrustManager[]{trustManager}, new SecureRandom()); |
98 | 98 | return new TrustProvider(sslContext, trustManager); |
@@ -120,7 +120,7 @@ private static KeyStore loadKeyStore(InputStream in, char[] password) |
120 | 120 | // registered fulfills the request. |
121 | 121 | byte[] bytes = in.readAllBytes(); |
122 | 122 | KeyStoreException last = null; |
123 | | - for (String type : Set.of(KeyStore.getDefaultType(), "JKS", "PKCS12")) { |
| 123 | + for (String type : new HashSet<>(List.of(KeyStore.getDefaultType(), "JKS", "PKCS12"))) { |
124 | 124 | try { |
125 | 125 | KeyStore ks = KeyStore.getInstance(type); |
126 | 126 | ks.load(new java.io.ByteArrayInputStream(bytes), password); |
|
0 commit comments