diff --git a/api/clients/v2/dispersal_request_signer.go b/api/clients/v2/dispersal_request_signer.go index 547c26974..871c36788 100644 --- a/api/clients/v2/dispersal_request_signer.go +++ b/api/clients/v2/dispersal_request_signer.go @@ -8,6 +8,7 @@ import ( grpc "github.com/Layr-Labs/eigenda/api/grpc/node/v2" "github.com/Layr-Labs/eigenda/api/hashing" aws2 "github.com/Layr-Labs/eigenda/common/aws" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/config" "github.com/aws/aws-sdk-go-v2/service/kms" ) @@ -31,6 +32,7 @@ type requestSigner struct { func NewDispersalRequestSigner( ctx context.Context, region string, + endpoint string, keyID string) (DispersalRequestSigner, error) { // Load the AWS SDK configuration, which will automatically detect credentials @@ -42,7 +44,16 @@ func NewDispersalRequestSigner( return nil, fmt.Errorf("failed to load AWS config: %w", err) } - keyManager := kms.NewFromConfig(cfg) + var keyManager *kms.Client + if endpoint != "" { + keyManager = kms.New(kms.Options{ + Region: region, + BaseEndpoint: aws.String(endpoint), + }) + } else { + keyManager = kms.NewFromConfig(cfg) + } + key, err := aws2.LoadPublicKeyKMS(ctx, keyManager, keyID) if err != nil { return nil, fmt.Errorf("failed to get ecdsa public key: %w", err) diff --git a/api/clients/v2/dispersal_request_signer_test.go b/api/clients/v2/dispersal_request_signer_test.go index 465b040fa..3e8daa9e7 100644 --- a/api/clients/v2/dispersal_request_signer_test.go +++ b/api/clients/v2/dispersal_request_signer_test.go @@ -100,7 +100,7 @@ func TestRequestSigning(t *testing.T) { request := auth.RandomStoreChunksRequest(rand) request.Signature = nil - signer, err := NewDispersalRequestSigner(context.Background(), region, keyID) + signer, err := NewDispersalRequestSigner(context.Background(), region, localstackHost, keyID) require.NoError(t, err) // Test a valid signature. diff --git a/disperser/cmd/controller/main.go b/disperser/cmd/controller/main.go index ba5f180e6..b59e6ecea 100644 --- a/disperser/cmd/controller/main.go +++ b/disperser/cmd/controller/main.go @@ -158,6 +158,7 @@ func RunController(ctx *cli.Context) error { requestSigner, err = clients.NewDispersalRequestSigner( context.Background(), config.AwsClientConfig.Region, + config.AwsClientConfig.EndpointURL, config.DisperserKMSKeyID) if err != nil { return fmt.Errorf("failed to create request signer: %v", err)