dlapiduz / certbot-s3front

Certbot CLI plugin for S3/CloudFront validation and installation
MIT License
584 stars 70 forks source link

NoCredentialsError #70

Closed WalshStephen closed 6 years ago

WalshStephen commented 6 years ago

OS: Ubuntu

I have installed the plugin via pip and set my two Access Key variables. When I run the following command...

sudo certbot --agree-tos -a certbot-s3front:auth \ --certbot-s3front:auth-s3-bucket <my_bucket_name> \ --certbot-s3front:auth-s3-region us-east-1 \ -i certbot-s3front:installer \ --certbot-s3front:installer-cf-distribution-id <my_distribution_ID> \ -d <my_domain> \ --renew-by-default --text

... I get the following error...

... Plugins selected: Authenticator certbot-s3front:auth, Installer certbot-s3front:installer Obtaining a new certificate Performing the following challenges: http-01 challenge for <my_domain> Starting new HTTP connection (1): 169.254.169.254 Cleaning up challenges Starting new HTTP connection (1): 169.254.169.254 Encountered exception during recovery Unable to locate credentials Traceback (most recent call last): File "/home/stephen/.local/lib/python2.7/site-packages/certbot/error_handler.py", line 103, in _call_registered self.funcs[-1]() File "/home/stephen/.local/lib/python2.7/site-packages/certbot/auth_handler.py", line 308, in _cleanup_challenges self.auth.cleanup(achalls) File "/usr/local/lib/python2.7/dist-packages/certbot_s3front/authenticator.py", line 85, in cleanup Key=self._get_key(achall)) File "/home/stephen/.local/lib/python2.7/site-packages/botocore/client.py", line 314, in _api_call return self._make_api_call(operation_name, kwargs) File "/home/stephen/.local/lib/python2.7/site-packages/botocore/client.py", line 599, in _make_api_call operation_model, request_dict) File "/home/stephen/.local/lib/python2.7/site-packages/botocore/endpoint.py", line 148, in make_request return self._send_request(request_dict, operation_model) File "/home/stephen/.local/lib/python2.7/site-packages/botocore/endpoint.py", line 173, in _send_request request = self.create_request(request_dict, operation_model) File "/home/stephen/.local/lib/python2.7/site-packages/botocore/endpoint.py", line 157, in create_request operation_name=operation_model.name) File "/home/stephen/.local/lib/python2.7/site-packages/botocore/hooks.py", line 227, in emit return self._emit(event_name, kwargs) File "/home/stephen/.local/lib/python2.7/site-packages/botocore/hooks.py", line 210, in _emit response = handler(**kwargs) File "/home/stephen/.local/lib/python2.7/site-packages/botocore/signers.py", line 90, in handler return self.sign(operation_name, request) File "/home/stephen/.local/lib/python2.7/site-packages/botocore/signers.py", line 156, in sign auth.add_auth(request) File "/home/stephen/.local/lib/python2.7/site-packages/botocore/auth.py", line 420, in add_auth super(S3SigV4Auth, self).add_auth(request) File "/home/stephen/.local/lib/python2.7/site-packages/botocore/auth.py", line 352, in add_auth raise NoCredentialsError NoCredentialsError: Unable to locate credentials An unexpected error occurred: NoCredentialsError: Unable to locate credentials Please see the logfiles in /var/log/letsencrypt for more details.

dlapiduz commented 6 years ago

@WalshStephen you have to set the environment variables for AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in order to get the plugin to connect to AWS.

ghost commented 5 years ago

I found out that I had to re-install awscli to get rid of this "NoCredentialsError". I had a corrupted, misconfigured or misinstalled version of it that the certbot was reading first instead of the exported variables that I set up even in my bash_profile.

PaulRBerg commented 5 years ago

I'm getting this error even if I made sure I set the environment variables correctly (AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY). Normally, I'm using AWS_DEFAULT_PROFILE, but I also got rid of that for testing purposes. In the same console, if I do aws s3 ls, it correctly prints the list of s3 buckets I own.

Just for the record, I also tried installing certbot in two different ways, via pip and then homebrew.

aws-cli/1.15.76 Python/3.6.0 Darwin/18.2.0 botocore/1.10.75
certbot 0.29.1

Update: Setting the global variables still didn't work, but changing one of my profile names in ~/.aws/credential to default made the trick. Apparently, other situations lead to the same workaround: https://github.com/thumbor-community/aws/issues/48