All Products
Search
Document Center

Alibaba Cloud SDK:Configure an HTTPS request

Last Updated:Feb 23, 2022

This topic describes how to configure an HTTPS request in the Darabonba SDK.

You can specify the protocols over which API requests are made in an SDK client by using the Darabonba SDK. The protocol settings in an SDK client take precedence over the default protocol settings. You can configure the runtime parameters to disable certificate verification. By default, certificate verification is enabled. If an API request is sent over HTTPS and no certificates are configured, an error is reported.

func main() {
   config := &openapi.Config{
    // Your AccessKey ID.
    AccessKeyId: tea.String("<AccessId>"),
    // Your AccessKey secret.
    AccessKeySecret: tea.String("<AccessSecret>"),
     // The region that you want to access.
    RegionId: tea.String("<RegionId>"),
    // Specify HTTPS or HTTP.
    Protocol: tea.String("HTTPS")
  }
  client, _err = ecs20140526.NewClient(config)
  if _err != nil {
    panic(err)
  }
  describeRegionsRequest := &ecs20140526.DescribeRegionsRequest{}
  // Create a RuntimeOptions instance and configure runtime parameters. 
  runtime := &util.RuntimeOptions{}
  // Ignore SSL certificate-related errors.
  runtime.IgnoreSSL = tea.Bool(true)
  resp, _err := client.DescribeRegionsWithOptions(describeRegionsRequest, runtime)
  if _err != nil {
    panic(err)
  }
  // The response, which contains the body and headers that are returned by the server side.
  body, err := json.Marshal(resp.Body)
  if err != nil {
    panic(err)
  }
  fmt.Printf("body: %s\n", string(body))
}