aws-sdk-cpp: Unable to get custom client working, missing signer?

Problem summary

I am able to generate the library for my custom client using the sdk (1.4.39 is my latest attempt). To do that, I used the aws apigateway get-export method to pull my c2j and then placing that in the required filename format into code-generation/api-descriptions. That is all working now (I have 4 static libs: aws-cpp-sdk-{core,mySanitizedApi,s3,transfer}.lib). Everything compiles and links without error. But when I try to use it (just in a test for now), I’m getting a debug assertion and a failure deep in the auth client mechanism – it is attempting to look up the authorizer name for my custom api in a list of “signers”, and isn’t finding it.

See sample code and trace level log below.

This API works with direct http URL crafting in a browser (passing the required request variable as a query parameter), and it also works without any special setup using C#. The api does not require credentials – it is intended to be anonymous. Its purpose is to retrieve some temp credentials on the server side based on the SanitizedRequestVariable.

I have tried initializing my client using the AnonymousAWSCredentialsProvider (as well as not specifying a provider at all, letting it default) – nothing is working (at least not in the c++ sdk generation of my custom client.

What platform/OS are you using?

Windows

What compiler are you using? what version?

Visual Studio 2015

What’s your CMake arguments?

-DBUILD_ONLY="s3;transfer" -DADD_CUSTOM_CLIENTS="serviceName=mySanitizedApi, version=2018-04-23" -DBUILD_SHARED_LIBS=OFF -DFORCE_SHARED_CRT=OFF -DENABLE_UNITY_BUILD=ON -DTARGET_ARCH="WINDOWS" -G "Visual Studio 14 2015 Win64"

Can you provide a TRACE level log? (sanitize any sensitive information)

[INFO] 2018-05-01 10:16:48 Aws_Init_Cleanup [14356] Initiate AWS SDK for C++ with Version:1.4.35
[INFO] 2018-05-01 10:16:48 WinHttpSyncHttpClient [14356] Creating http client with user agent aws-sdk-cpp/1.4.35 Windows/10.0.15063.608 AMD64 with max connections 25 request timeout 10000,and connect timeout 3000
[INFO] 2018-05-01 10:16:48 WinHttpSyncHttpClient [14356] Http Client is using a proxy. Setting up proxy with settings scheme http, host mysanitizedproxy.net, port 8080, username 
[DEBUG] 2018-05-01 10:16:48 WinHttpSyncHttpClient [14356] Adding proxy host string to winhttp HTTPS=http://mysanitizedproxy.net:8080
[DEBUG] 2018-05-01 10:16:48 WinHttpSyncHttpClient [14356] API handle 000001A9DC465AF0
[INFO] 2018-05-01 10:16:48 ConnectionPoolMgr [14356] Creating connection pool mgr with handle 000001A9DC465AF0, and max connections per host 25, request timeout 10000 ms, and connect timeout in 3000 ms.
[TRACE] 2018-05-01 10:16:48 AWSClient [14356] No content body, content-length headers
[ERROR] 2018-05-01 10:16:48 AuthSignerProvider [14356] Request's signer: 'mySanitizedApiAuthorizer' is not found in the signer's map.
[DEBUG] 2018-05-01 10:16:54 WinSyncHttpClient [14356] Cleaning up client with handle 0000000000000000
[INFO] 2018-05-01 10:16:54 WinHttpConnectionPoolMgr [14356] Cleaning up conneciton pool mgr.
[INFO] 2018-05-01 10:22:42 Aws_Init_Cleanup [504] Initiate AWS SDK for C++ with Version:1.4.35
[INFO] 2018-05-01 10:22:42 WinHttpSyncHttpClient [504] Creating http client with user agent aws-sdk-cpp/1.4.35 Windows/10.0.15063.608 AMD64 with max connections 25 request timeout 10000,and connect timeout 3000
[INFO] 2018-05-01 10:22:42 WinHttpSyncHttpClient [504] Http Client is using a proxy. Setting up proxy with settings scheme http, host mysanitizedproxy.net, port 8080, username 
[DEBUG] 2018-05-01 10:22:42 WinHttpSyncHttpClient [504] Adding proxy host string to winhttp HTTPS=http://mysanitizedproxy.net:8080
[DEBUG] 2018-05-01 10:22:42 WinHttpSyncHttpClient [504] API handle 000001C3C40BDC90
[INFO] 2018-05-01 10:22:42 ConnectionPoolMgr [504] Creating connection pool mgr with handle 000001C3C40BDC90, and max connections per host 25, request timeout 10000 ms, and connect timeout in 3000 ms.
[TRACE] 2018-05-01 10:25:20 AWSClient [504] No content body, content-length headers
[ERROR] 2018-05-01 10:29:12 AuthSignerProvider [504] Request's signer: 'mySanitizedApiAuthorizer' is not found in the signer's map.
[DEBUG] 2018-05-01 10:29:23 WinSyncHttpClient [504] Cleaning up client with handle 0000000000000000
[INFO] 2018-05-01 10:29:23 WinHttpConnectionPoolMgr [504] Cleaning up conneciton pool mgr.

Sample code

#define TAG "mySanitizedApiTest"

TEST_METHOD(mySanitizedApiPass)
{
	auto config = Aws::MakeShared<Aws::Client::ClientConfiguration>(TAG);
	config->scheme = Aws::Http::Scheme::HTTPS;
	config->requestTimeoutMs = 10000; // 10 seconds
	config->connectTimeoutMs = 3000; // 3 seconds
	config->retryStrategy = Aws::MakeShared<Aws::Client::DefaultRetryStrategy>(TAG, 5, 10);
	config->proxyScheme = Aws::Http::Scheme::HTTP;
	config->proxyHost = "mysanitizedproxy.net";
	config->proxyPort = 8080;

	//auto credentialsProvider = Aws::MakeShared<Aws::Auth::AnonymousAWSCredentialsProvider>(TAG);
	//auto client = Aws::MakeShared<Aws::mySanitizedApi::mySanitizedApiClient>(TAG, credentialsProvider, *config);
	auto client = Aws::MakeShared<Aws::mySanitizedApi::mySanitizedApiClient>(TAG, *config);
	auto request = Aws::MakeShared<Aws::mySanitizedApi::Model::GetCredentialsRequest>(TAG);
	request->SetSanitizedRequestVariable(_sanitizedValue);
	auto outcome = client->GetCredentials(*request);
	Assert::IsTrue(outcome.IsSuccess());
}

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Comments: 23 (6 by maintainers)

Most upvoted comments

Hi @mattman71 sorry for letting you wait for such a long time. We just pushed this commit: https://github.com/aws/aws-sdk-cpp/commit/ebcc3ded77ea8a9b39e18676b2d54a91712b009f, in which

  1. Fixed the URI bug, appending .execute-api to the endpoint.
  2. Added support to define custom signer including null signer in the client constructor.
  3. Added a test to show an example of how to define custom singer and make use of it
  4. Added a build script to show how to generate, build and make use of a custom client: https://github.com/aws/aws-sdk-cpp/blob/master/scripts/build_custom_client.sh. We will run it with every future release to make sure it’s always compatible with aws-cpp-sdk-core. You can find the api description file here, which is a very basic example provided by API Gateway.

And more details about how to “generate custom client”, after this commit, we will support two approaches:

  1. With cmake flag -DADD_CUSTOM_CLIENT, I think that’s how you generate client right now. In this approach, we treat custom client as any other AWS service, and build aws-cpp-sdk-core together with custom client.
  2. With python script specified in the build script. In this approach, we take custom client as a separate package, which means we have to build and install aws-cpp-sdk-core as a dependency. And that’s expected to be the approach we use in the future if we integrate custom client code generation in API Gateway console, like Java, Ruby. You can download the source code(including the cmake file) from API Gateway console and build custom client on the machine with aws-cpp-sdk-core library built and installed.

Please let us know if that meets your requirements or you have more questions.

No worries, it was just a tiny one line that scrolled, and I tend to throw up walls of text; easy to get lost in the noise. 😆

If you look above at my comment on May 17, the aws apigateway command is what does that part. Just fill in the appropriate parameters for your rest api id, the name of the stage where you’ve published your api gateway, the region you’re hosting in, etc.

After all of that, you may still get stuck because of the above 2 bugs, but I think they’re very close to delivering fixes for those.

You may not be affected by the signer problem if you’re not using a custom authorizer in your api gateway. But you’ll likely be affected by the endpoint bug – the generator leaves out the .execute-api. part of the URL for the endpoint. If you’re not concerned with build automation, you can fix that with a quick manual edit in the json file you get from your c2j.zip and place into api-descriptions. There will be an endpoint key/value in there, and you can just append .execute-api to it – you’ll figure out what I mean when you see it; it’s basically constructing the url with string concatenation, and you just have to add the missing piece to the unique encoded part of the beginning of your url, so that when it appends the rest of the suffix, it’ll all work together. Clear as mud, right? 🤣

So sorry about the delay, we added more tests(including some sample code about how to add null signer to the client). We will merge these code in one week.

Updated: Code are under review.