<?php
namespace app\admin\controller;
use Aws\AwsClient;
use Aws\Acm\AcmClient;
use Aws\Credentials\CredentialProvider;
class AWSUtil{
public function init(){
$acmClient = new AcmClient([
'region' => 'us-east-1',
'version' => '2015-12-08',
'credentials'=>[
// 'id'=>"851725259723",
'key'=>"AKIA4MTWICPFTJEVQ25E",
"secret"=>"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"
]
]);
$result = $acmClient->requestCertificate([
'DomainName' => 'ddddddddddddddddddd.com',
'IdempotencyToken' => "1234",
'Options' => [
'CertificateTransparencyLoggingPreference' => 'DISABLED',
],
'ValidationMethod' => 'DNS',
]);
return $result->get("CertificateArn");
}
}
接口返回内容:
Model Data
----------
Data can be retrieved from the model object using the get() method of the
model (e.g., `$result->get($key)`) or "accessing the result like an
associative array (e.g. `$result['key']`). You can also execute JMESPath
expressions on the result data using the search() method.
{
"CertificateArn": "arn:aws:acm:us-east-1:851725259723:certificate\/9fb07269-f4d2-43b2-97bd-a0d0caff1639",
"@metadata": {
"statusCode": 200,
"effectiveUri": "https:\/\/acm.us-east-1.amazonaws.com",
"headers": {
"x-amzn-requestid": "cb49fac1-1933-4928-a6e0-bece59993b5a",
"content-type": "application\/x-amz-json-1.1",
"content-length": "104",
"date": "Tue, 12 Nov 2024 08:11:28 GMT",
"connection": "close"
},
"transferStats": {
"http": [
[]
]
}
}
}
后台看到了我们用代码申请的证书:
拿着这个domain地址ddddddddddddd.com 和返回的证书内容CertificateArn去到域名后台配置映射。如下图第一步: