

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 将条件键与 ACM 结合使用
<a name="acm-conditions"></a>

AWS Certificate Manager 使用 AWS Identity and Access Management (IAM) [条件密钥](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html)限制对证书请求的访问。使用 IAM policy 或服务控制策略（SCP）中的条件密钥，您可以创建符合组织准则的证书请求。

**注意**  
将 ACM 条件键与 AWS [全局条件键](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html)相结合`aws:PrincipalArn`，例如进一步限制对特定用户或角色的操作。

## 支持的 ACM 条件
<a name="acm-conditions-supported"></a>

使用滚动条查看表的其余部分。


**ACM API 操作和支持的条件**  

| 条件键 | 支持的 ACM API 操作 | Type | 说明 | 
| --- | --- | --- | --- | 
|  `acm:ValidationMethod`  |  [RequestCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html)  |  字符串（`DNS`，`EMAIL`，`HTTP`）  |  依据 ACM [验证方法](https://docs.aws.amazon.com/acm/latest/userguide/domain-ownership-validation.html)筛选请求  | 
|  `acm:DomainNames`  |  [RequestCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html)  |  ArrayOfString  |  依据 ACM 请求中的[域名](https://docs.aws.amazon.com/acm/latest/userguide/acm-concepts.html#concept-dn)筛选  | 
|  `acm:KeyAlgorithm`  |  [RequestCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html)  |  字符串  |  依据 ACM [密钥算法和大小](https://docs.aws.amazon.com/acm/latest/userguide/acm-certificate.html#algorithms)筛选请求  | 
|  `acm:CertificateTransparencyLogging`  |  [RequestCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html)  |  字符串（`ENABLED`，`DISABLED`）  |  依据 ACM [证书透明度日志记录首选项](https://docs.aws.amazon.com/acm/latest/userguide/acm-concepts.html#concept-transparency)筛选请求  | 
|  `acm:CertificateAuthority`  |  [RequestCertificate](https://docs.aws.amazon.com/acm/latest/APIReference/API_RequestCertificate.html)  |  进行筛选  |  依据 ACM 请求中的[证书颁发机构](https://docs.aws.amazon.com/acm/latest/userguide/acm-concepts.html#concept-ca)筛选请求  | 

## 示例 1：限制验证方法
<a name="conditions-validation"></a>

以下策略使用[电子邮件验证](https://docs.aws.amazon.com/acm/latest/userguide/domain-ownership-validation.html)方法来拒绝新的证书请求，但使用 `arn:aws:iam::123456789012:role/AllowedEmailValidation` 角色发出的请求除外。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition":{
            "StringLike" : {
                "acm:ValidationMethod":"EMAIL"
            },
            "ArnNotLike": {
                "aws:PrincipalArn": [ "arn:aws:iam::123456789012:role/AllowedEmailValidation"]
            }
        }
    }
}
```

------

## 示例 2：阻止通配符域
<a name="conditions-wildcards"></a>

以下策略拒绝使用通配符域的任何新 ACM 证书请求。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition": {
            "ForAnyValue:StringLike": {
                "acm:DomainNames": [
                    "${*}.*"
                ]
            }
        }
    }
}
```

------

## 示例 3：限制证书域
<a name="conditions-restrictdomains"></a>

以下策略拒绝非 `*.amazonaws.com` 结尾的域的任何新 ACM 证书请求

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition": {
            "ForAnyValue:StringNotLike": {
                "acm:DomainNames": ["*.amazonaws.com"]
            }
        }
    }
}
```

------

该策略可以进一步限制为特定的子域。此政策仅允许其中每个域都与至少一个条件域名匹配的请求。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition": {
            "ForAllValues:StringNotLike": {
                "acm:DomainNames": ["support.amazonaws.com", "developer.amazonaws.com"]
            }
        }
    }
}
```

------

## 示例 4：限制密钥算法
<a name="conditions-keyalgorithm"></a>

以下策略使用条件密钥 `StringNotLike` 来仅允许使用 ECDSA 384 位 (`EC_secp384r1`) 密钥算法请求的证书。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
        "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition":{
            "StringNotLike" : {
                "acm:KeyAlgorithm":"EC_secp384r1"
            }
        }
    }
}
```

------

以下策略使用条件密钥 `StringLike` 和通配符 `*` 匹配来阻止在 ACM 中使用任何 `RSA` 密钥算法的新证书。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition":{
            "StringLike" : {
                "acm:KeyAlgorithm":"RSA*"
            }
        }
    }
}
```

------

## 示例 5：限制证书颁发机构
<a name="conditions-publicca"></a>

以下策略仅允许使用提供的私有证书颁发机构（PCA）ARN 的私有证书请求。

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition":{
            "StringNotLike": {
                "acm:CertificateAuthority":" arn:aws:acm-pca:region:account:certificate-authority/CA_ID"
            }
        }
    }
}
```

------

此策略使用 `acm:CertificateAuthority` 条件来仅允许 Amazon Trust Services 颁发的公开信任证书的请求。将证书颁发机构 ARN 设置为 `false` 能阻止来自 PCA 的私有证书请求。

------
#### [ JSON ]

****  

```
{
"Version":"2012-10-17",		 	 	 
    "Statement":{
        "Effect":"Deny",
        "Action":"acm:RequestCertificate",
        "Resource":"*",
        "Condition":{
            "Null" : {
                "acm:CertificateAuthority":"false"
            }
        }
    }
}
```

------