Skip to content

Latest commit

 

History

History
50 lines (35 loc) · 1.58 KB

5-HTTPS-EN.md

File metadata and controls

50 lines (35 loc) · 1.58 KB

← Timeout | HTTPS Configurations(中文) | Proxy Configurations →


Use HTTPS for request

request.setSysProtocol(com.aliyuncs.http.ProtocolType.HTTPS);

HTTPS Configurations

Priority: Client > Default

  1. Ignore certificate

This must be set when the project first creates the client. Otherwise you need to close the last client with the command ApacheHttpClient.getInstance().close().

// Client HTTPS configurations
HttpClientConfig clientConfig = HttpClientConfig.getDefault();
// Configure not to verify the server certificates
clientConfig.setIgnoreSSLCerts(true);

IClientProfile profile = DefaultProfile.getProfile(regionId, accesskeyId, accesskeySecret);
profile.setHttpClientConfig(clientConfig);
DefaultAcsClient client = new DefaultAcsClient(profile);
 
  1. Customize the configuration of certificate validation

KeyManager and X509TrustManager are the interface. User implementation is required.

// Client HTTPS configurations
HttpClientConfig clientConfig = HttpClientConfig.getDefault();
// Configure user-defined TrustManagers
clientConfig.setX509TrustManagers(clientTrustManagers);
// Configure user-defined KeyManagers
clientConfig.setKeyManagers(clientKeyManagers);

IClientProfile profile = DefaultProfile.getProfile(regionId, accesskeyId, accesskeySecret);
profile.setHttpClientConfig(clientConfig);
DefaultAcsClient client = new DefaultAcsClient(profile);
 

← Timeout | HTTPS Configurations(中文) | Proxy Configurations →