Alibaba Cloud Darabonba SDK allows you to specify the protocol over which API requests are sent for an SDK client. We recommend that you send API requests over HTTPS. If you do not specify the protocol, API requests are sent over HTTPS by default.
// Specify HTTPS as the protocol.
$config = new Config([]);
$config->protocol = "HTTPS";
By default, if you send an API request over HTTPS, the SDK enables certificate verification to verify the validity of SSL/TLS certificates. If no SSL/TLS certificate is configured in the development environment, an error that indicates the certificate verification fails is reported.
To ensure network communication security, we recommend that you enable certificate verification. If certificate verification must be disabled in the test environment, you can set the ignoreSSL
parameter to true when you specify runtime parameters.
// Specify a timeout period by using runtime parameters. The timeout period takes effect only on the requests that use the RuntimeOptions instance.
$runtimeOptions = new RuntimeOptions();
// If you set the ignoreSSL parameter to true, certificate verification is disabled. If you set the ignoreSSL parameter to false, certificate verification is enabled.
$runtimeOptions->ignoreSSL = true;
The following sample code provides an example on how to configure an HTTPS request:
use Darabonba\OpenApi\Models\Config;
use AlibabaCloud\Credentials\Credential;
use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions;
use AlibabaCloud\SDK\Ecs\V20140526\Ecs;
use AlibabaCloud\SDK\Ecs\V20140526\Ecs\Models\DescribeRegionsRequest;
// Use the default credentials to initialize the Credentials client.
$credential = new Credential([]);
$config = new Config([
'credential' => $credential
]);
// Specify HTTPS as the protocol.
$config->protocol = "HTTPS";
// Specify a timeout period by using runtime parameters. The timeout period takes effect only on the requests that use the RuntimeOptions instance.
$runtimeOptions = new RuntimeOptions();
// If you set the ignoreSSL parameter to true, certificate verification is disabled. If you set the ignoreSSL parameter to false, certificate verification is enabled.
$runtimeOptions->ignoreSSL = true;
$request = new DescribeRegionsRequest();
$client = new Ecs($config);
$client->describeRegionsWithOptions($request, $runtimeOptions)