HTTPS request configuration
The V2.0 SDK accesses Alibaba Cloud services over HTTPS by default. To switch protocols, set the protocol parameter of the com.aliyun.teaopenapi.models.Config class to HTTP or HTTPS. We recommend HTTPS for secure data transmission.
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config();
config.setProtocol("HTTPS");
The SDK verifies SSL/TLS certificates by default for HTTPS connections. If your environment lacks the required certificates, verification may fail. Use the ignoreSSL parameter of the com.aliyun.teautil.models.RuntimeOptions class to skip certificate verification. For example, set ignoreSSL to true in a staging environment to bypass verification during testing.
Enable SSL/TLS certificate validation in production environments.
com.aliyun.teautil.models.RuntimeOptions runtimeOptions = new com.aliyun.teautil.models.RuntimeOptions();
// true: skip certificate validation, false: validate certificates (default is false)
runtimeOptions.ignoreSSL = true;
Common HTTPS connection issues
Java client reports Connection reset error
Java applications calling APIs over HTTPS may encounter a Connection reset or javax.net.ssl.SSLException error, even when the same URL works in a browser. This typically occurs when the Java runtime's default TLS version does not match what the server requires.
Root cause
-
JDK 7 and earlier versions use TLS 1.0 by default. JDK 8 uses TLS 1.2 by default.
-
The target server has disabled TLS 1.0 and TLS 1.1 and only supports TLS 1.2 or higher.
-
Browsers negotiate the highest supported TLS version automatically, but Java clients use the JDK default, which can cause mismatches.
Solution
After creating a Config object, explicitly set the TLS version to 1.2 using either a JVM argument or code.
-
Option 1: Set a JVM startup argument
Add the following parameter to your start command:
java -Dhttps.protocols=TLSv1.2 -jar your-app.jar -
Option 2: Specify the TLS version in code
// Set the system property at the program entry point System.setProperty("https.protocols", "TLSv1.2");
After applying the change, restart your application and verify that HTTPS calls succeed. If errors persist, verify that the TLS versions and cipher suites supported by the target server are compatible with your Java environment.