awslabs / awslabs/aws-lambda-cpp

Error during sending a signed http request to ElasticSearch

オープン
#188 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
C++
スター
465
フォーク
98
平均マージ
12時間 47分
マージ済み PR(30日)
3

説明

hey,
I am running into an error while making a httprequest to Elastic Search The error is

> The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method

Following is the code. Any pointers to bug in my code or library would be appreciated.

```
`invocation_response my_handler(invocation_request const& request)
{
ClientConfiguration config;
config.region = Aws::Environment::GetEnv("AWS_REGION");
config.caFile = "/etc/pki/tls/certs/ca-bundle.crt";
auto credentialsProvider = Aws::MakeShared("es");

auto client = CreateHttpClient(config);
auto httpRequest = CreateHttpRequest(URL, HttpMethod::HTTP_GET,
Aws::Utils::Stream::DefaultResponseStreamFactoryMethod);

httpRequest->SetContentType("application/json");

nlohmann::json query1 = {};
query1.emplace("size", 25);

std::shared_ptr sstream = make_shared();
*sstream << query1;
httpRequest->AddContentBody(sstream);
Aws::Client::AWSAuthV4Signer signer(credentialsProvider, "es", config.region);
auto req = httpRequest.get();
signer.SignRequest(*req);
auto outcome = client->MakeRequest(httpRequest);
if (outcome->GetResponseCode() == HttpResponseCode::OK) {
cout << "SUCCESS" << endl;
} else {
// print the response from the http request
cout << "ERROR" << endl;
cout << outcome->GetResponseBody().rdbuf() << endl;
cout << outcome->GetResponseCode() << endl;

}`

```

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

Issueに示されているリクエストの構築と Aws::Client::AWSAuthV4Signer::SignRequest の呼び出しから始め、設定されたリージョンと環境認証情報を使用して Elasticsearch に対するリクエストを再現します。署名の入力値とサービスのレスポンスを比較します。ライブラリの不具合を最小限の再現で確認するか、呼び出し側の設定の修正を文書化できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
aws, cpp, elasticsearch
領域
api, cloud, security
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。