简体   繁体   English

尝试使用 Certbot 和 Route53 插件获取通配符 SSL 时出现 AccessDenied 错误

[英]Getting AccessDenied Error Trying to Get Wildcard SSL with Certbot and Route53 Plugin

I have been tasked with setting up Wilcard SSL for some domains.我的任务是为某些域设置 Wilcard SSL。 These domains are hosted through AWS Route53.这些域通过 AWS Route53 托管。

I am using Certbot on an Ubuntu 20.4 machine, where the apps are hosted.我在托管应用程序的Ubuntu 20.4机器上使用Certbot I have also installed the Route53 DNS plugin for Certbot.我还为 Certbot 安装了 Route53 DNS 插件。

I run this command:我运行这个命令:

sudo certbot certonly --dns-route53 --email 'me@derp.com' --domain 'mywebsite.rocks' --domain '*.mywebsite.rocks' --agree-tos --non-interactive

Real domains remove for security reasons出于安全原因删除真实域

I get this error:我收到此错误:

An error occurred (AccessDenied) when calling the ListHostedZones operation: User: arn:aws:sts::789148085273:assumed-role/AmazonLightsailInstanceRole/i-0871f2572906140c4 is not authorized to perform: route53:ListHostedZones because no identity-based policy allows the route53:ListHostedZones action

Let me explain first how I set up the IAM user in the AWS console.首先让我解释一下我是如何在 AWS 控制台中设置 IAM 用户的。

  1. I created a new Policy with this config我使用此配置创建了一个新策略
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Sid": "derp0",
            "Effect": "Allow",
            "Action": [
                "route53:GetHostedZone",
                "route53:ChangeResourceRecordSets",
                "route53:ListResourceRecordSets"
            ],
            "Resource": "arn:aws:route53:::hostedzone/WHAT-EVER-MY-ID-IS-HERE"
        },
        {
            "Sid": "derp1",
            "Effect": "Allow",
            "Action": "route53:ListHostedZones",
            "Resource": "*"
        }
    ]
}

Replacing WHAT-EVER-MY-ID-IS-HERE with my actual domain's Hosted Zone ID用我的实际域的托管区域 ID 替换WHAT-EVER-MY-ID-IS-HERE

  1. I then created a new IAM User and during set-up, I attached the above Policy to the user.然后我创建了一个新的IAM 用户,并在设置过程中将上述策略附加到该用户。

  2. I then created an Access Key for my new User and took note of the AccessKeyId and SecretAccessKey .然后,我为我的新用户创建了一个访问密钥,并记下了AccessKeyIdSecretAccessKey This has access to be used programmatically.这可以以编程方式使用。

  3. On the server, I created a config file at /root/.aws/config as instructed in the documentation.在服务器上,我按照文档中的说明在/root/.aws/config中创建了一个配置文件。 I also tried ~/.aws/config but as I am using sudo the former seemed the preferred location (I could be wrong though, and during my tests, neither worked anyway)我也试过~/.aws/config但因为我使用sudo前者似乎是首选位置(虽然我可能是错的,并且在我的测试期间,无论如何都没有用)

And as previously aforementioned, I run the command and get the error.如前所述,我运行命令并收到错误。

Searched the web high and low for a solution, but cannot find one.在web上下找了解决办法,没找到。

Appreciate any help I can get from folk.感谢我能从民间获得的任何帮助。

After a quick check, I was able to find the following article:快速检查后,我找到了以下文章:

https://certbot-dns-route53.readthedocs.io/en/stable/ https://certbot-dns-route53.readthedocs.io/en/stable/

Have a look at it, it might help you to set the necessary policy.看看它,它可能会帮助您设置必要的策略。

Of course, if using AWS is not a must, you can always just deploy the website to another provider where there would not be necessary to set up policies and everything will get through just fine.当然,如果不是必须使用 AWS,您始终可以将网站部署到另一个提供商,而无需设置策略,一切都会顺利进行。

What you'll have to do is click on 'Roles' link under 'Access Management':您需要做的是单击“访问管理”下的“角色”链接: 在此处输入图像描述

Then search for the 'role' that is causing the error because it has insufficient permissions so in your case, your error message indicates that it's the 'AmazonLightsailInstanceRole'.然后搜索导致错误的“角色”,因为它没有足够的权限,因此在您的情况下,您的错误消息表明它是“AmazonLightsailInstanceRole”。 Once you find that role, attach a policy that has the permission 'route53:ListHostedZones'.找到该角色后,附加一个具有“route53:ListHostedZones”权限的策略。 Not sure why your error message is showing an 'assumed-role' for 'AmazonLightsailInstanceRole' but mine was 'AmazonSSMRoleForInstancesQuickSetup' that was giving me the same error you were getting.不确定为什么您的错误消息显示“AmazonLightsailInstanceRole”的“假定角色”,但我的是“AmazonSSMRoleForInstancesQuickSetup”,它给我的错误与您遇到的错误相同。 But after I attached a policy that had the permissions specified by 'certbot-dns-rout53', it was able to get and install a certificate.但是在我附加了一个具有“certbot-dns-rout53”指定权限的策略之后,它能够获取并安装证书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM