Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

blob/: Connecting to AWS with AWS_CA_BUNDLE and GS afterwards fails #3148

Closed
jastBytes opened this issue Aug 1, 2022 · 3 comments
Closed

Comments

@jastBytes
Copy link

Describe the bug

I have a service which synchronizes two buckets using the CDK. The source bucket is hosted using Ceph S3 with a custom CA. Therefore I specify AWS_CA_BUNDLE when opening the bucket. The target bucket is hosted in GS, nothing special here. My service opens the bucket in Ceph S3 first and then in GS. When using the GS bucket the following error message is shown:

Error: failed to list bucket: blob (code=Unknown):
Get "https://storage.googleapis.com/storage/v1/b/testbucket/o?alt=json&delimiter=&endOffset=&maxResults=1000&pageToken=&prefix=&prettyPrint=false&projection=full&startOffset=&versions=false":
oauth2: cannot fetch token: Post "https://oauth2.googleapis.com/token":
x509: certificate signed by unknown authority

I think the root cause is, that both the AWS SDK and the Googleapis SDK use http.DefaultClient and/or http.DefaultTransport. The code loading the custom CA for AWS edits the http.DefaultTransport and all subsequent usages of those DefaultClient/-Transport will use the custom CA no matter if that is intended or not.

To Reproduce

  1. Specify custom CA for AWS SDK using AWS_CA_BUNDLE
  2. Open bucket connection to some bucket with s3://...
  3. Open bucket connection to some bucket with gs://...
  4. List GS bucket

Expected behavior

GS connection should not use custom CA.

Version

v0.25.0

@jastBytes
Copy link
Author

As a mitigation you can do the following between two OpenBucket calls:

// Clear defaults to take over custom CAs or other customized settings
http.DefaultClient = &http.Client{}
http.DefaultTransport = &http.Transport{}

@jastBytes
Copy link
Author

I suspect this is basically a bug with the AWS SDK and not this CDK: aws/aws-sdk-go#4496

@vangent
Copy link
Contributor

vangent commented Aug 1, 2022

I suspect this is basically a bug with the AWS SDK and not this CDK: aws/aws-sdk-go#4496

Yep, thanks!

@vangent vangent closed this as completed Aug 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants