Skip to content

Commit d1570a2

Browse files
committed
keep old public class for compatible
1 parent ea60267 commit d1570a2

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

aliyun-java-sdk-core/src/main/java/com/aliyuncs/http/clients/CompatibleUrlConnClient.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,12 @@
1111
import javax.xml.bind.DatatypeConverter;
1212
import java.io.*;
1313
import java.net.*;
14+
import java.security.KeyManagementException;
1415
import java.security.KeyStore;
1516
import java.security.KeyStoreException;
1617
import java.security.NoSuchAlgorithmException;
18+
import java.security.cert.CertificateException;
19+
import java.security.cert.X509Certificate;
1720
import java.util.ArrayList;
1821
import java.util.Arrays;
1922
import java.util.List;
@@ -340,4 +343,26 @@ private Proxy getProxy(String envProxy, HttpRequest request) throws MalformedURL
340343
}
341344
return proxy;
342345
}
346+
347+
/**
348+
* use HttpClientConfig.setIgnoreSSLCerts(true/false) instead
349+
*/
350+
@Deprecated
351+
public static final class HttpsCertIgnoreHelper {
352+
/**
353+
* use HttpClientConfig.setIgnoreSSLCerts(false) instead
354+
*/
355+
@Deprecated
356+
public static void restoreSSLCertificate() {
357+
throw new IllegalStateException("use HttpClientConfig.setIgnoreSSLCerts(false) instead");
358+
}
359+
360+
/**
361+
* use HttpClientConfig.setIgnoreSSLCerts(true) instead
362+
*/
363+
@Deprecated
364+
public static void ignoreSSLCertificate() {
365+
throw new IllegalStateException("use HttpClientConfig.setIgnoreSSLCerts(true) instead");
366+
}
367+
}
343368
}

aliyun-java-sdk-core/src/test/java/com/aliyuncs/http/clients/CompatibleUrlConnClientTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -775,4 +775,21 @@ public void testRequestLevelIgnoreSSLCert() throws ClientException, IOException
775775
}
776776

777777
}
778+
779+
@Test
780+
public void testHttpsCertIgnoreHelperConstructor() {
781+
Assert.assertNotNull(new CompatibleUrlConnClient.HttpsCertIgnoreHelper());
782+
}
783+
784+
@Test
785+
public void testHttpsCertIgnoreHelperIgnore() {
786+
thrown.expect(IllegalStateException.class);
787+
CompatibleUrlConnClient.HttpsCertIgnoreHelper.ignoreSSLCertificate();
788+
}
789+
790+
@Test
791+
public void testHttpsCertIgnoreHelperRestore() {
792+
thrown.expect(IllegalStateException.class);
793+
CompatibleUrlConnClient.HttpsCertIgnoreHelper.restoreSSLCertificate();
794+
}
778795
}

0 commit comments

Comments
 (0)