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

Certificate path detection is incorrect when using AWS STS (eg with AWS EKS) #1129

Open
poodlewars opened this issue Dec 5, 2023 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@poodlewars
Copy link
Collaborator

poodlewars commented Dec 5, 2023

Describe the bug

The Azure we detect (using the openssl python lib) correct certificate locations, and use them in the Azure SDK.

For S3, we use the system default. But since we build on manylinux, and statically link libcurl and openssl, this means the "system default" we end up using is CentOS', which can lead to problems when running on other Linuxes.

Example failing flow:

  • Use passwordless authentication
  • Assume IAM role using AWS STS
  • The SSL verification with STS fails

On S3, we should use the same certificate location detection logic that we have for Azure.

There is a private thread that Alex Seaton can add you to about this with more context, https://arcticdb.slack.com/archives/C064NA7BK5H/p1701703865582509 .

@poodlewars poodlewars added the bug Something isn't working label Dec 5, 2023
@poodlewars poodlewars assigned poodlewars and unassigned poodlewars Dec 5, 2023
@poodlewars
Copy link
Collaborator Author

We should set up our own AWS EKS cluster so we can test this properly.

@phoebusm
Copy link
Collaborator

Plan for the development

  1. Verify verifySSL works with S3
  2. Make EKS works
  3. Unit test them

@poodlewars
Copy link
Collaborator Author

poodlewars commented Jan 2, 2024

I've been setting up a test AWS EKS cluster to help with this. I've put the deployment files here: https://github.com/poodlewars/scratch/tree/k8s-files .

.
├── deployment.apps
│   └── eks-sample-linux-deployment.yaml
├── service
│   └── eks-sample-linux-service.yaml
└── serviceaccount
    └── k8s-svc2.yaml

On Amazon Linux, this works out of the box, as it has the RHEL style cert locations.

With an Ubuntu image, this fails. Interesting it still fails on a Conda based install (mamba) even though we dynamically link openssl there?

I've set up a cluster alex-cluster-fargate in our AWS. You can set up kubectl to point at it with these notes. https://docs.aws.amazon.com/eks/latest/userguide/create-kubeconfig.html .

This was mostly following the fargate version of these notes, https://docs.aws.amazon.com/eks/latest/userguide/getting-started-eksctl.html then applying the configs above.

@phoebusm
Copy link
Collaborator

phoebusm commented Mar 18, 2024

Test passes with Conda installation in centos and ubuntu. Possible reason is:

  1. libcurl and openssl are dynamically linked
  2. openssl in conda has specifeid a os-independent location for ca file, e.g. cafile='/root/miniforge3/envs/py310/ssl/cert.pem'

@phoebusm
Copy link
Collaborator

At the moment, S3 SDK doesn't allow manually setting ca cert path for EKS, due to the corresponding settings is not being passed to it: https://github.com/aws/aws-sdk-cpp/blob/e9d0d247be909ade39f213a3e2915aa262755a78/src/aws-cpp-sdk-core/source/auth/STSCredentialsProvider.cpp#L110
I can think of three ways to fix the problem:

  1. Utilise the not-in-use
    MyAWSCredentialsProviderChain::MyAWSCredentialsProviderChain() : Aws::Auth::AWSCredentialsProviderChain() {
    to design our own AWSCredentialsProvider derived, which supports setting ca path
  2. Make libcurl dynamically linked in pypi, as in conda
  3. Patch S3 SDK to support loading CA path setting. Easiest way is probably by setting some environment variable.

@phoebusm
Copy link
Collaborator

phoebusm commented Mar 22, 2024

We are going to dynamically linked libcurl in vcpkg build. A few things are needed to be done:

  • Which version openssl should we dynamically link to?
  • openssl only maintains ABI compatibility in major version
  • We use 1.1.1 in vcpkg and not specified in conda (currently >3)
  • How to strip openssl library in auditwheel
  • Make vcpkg only dynamically linked openssl
  • Test whether the dynimic linkage can solve the problem we face in AWS STS

@phoebusm phoebusm linked a pull request Mar 22, 2024 that will close this issue
5 tasks
@phoebusm
Copy link
Collaborator

phoebusm commented Apr 11, 2024

We are going to dynamically linked libcurl in vcpkg build. A few things are needed to be done:...

The plan was scrapped as the decision is irreversible and maintainence debt for the future new version of openssl. Now we will stick to patching S3 SDK STS authentication class to make it follow the setting of caPath and caFIle in client config

aws/aws-sdk-cpp#2920

@phoebusm phoebusm removed a link to a pull request Apr 11, 2024
5 tasks
@poodlewars poodlewars changed the title Certificate path detection is incorrect for S3 Certificate path detection is incorrect for when using AWS STS (eg with AWS EKS) Jun 3, 2024
@poodlewars poodlewars changed the title Certificate path detection is incorrect for when using AWS STS (eg with AWS EKS) Certificate path detection is incorrect when using AWS STS (eg with AWS EKS) Jun 4, 2024
@poodlewars poodlewars added enhancement New feature or request and removed bug Something isn't working labels Nov 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants