1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-23 00:00:06 +01:00
libwebsockets/minimal-examples-lowlevel/secure-streams/minimal-secure-streams-sigv4
Andy Green 53d195022f cmake: Enable WITH_MINIMAL_EXAMPLES by default
Although many of the examples must be run from the example directory as
cwd, everyone getting started probably wants to try the examples, cmake
knows how to do it, so let's enable it by default.
2021-11-11 11:52:46 +00:00
..
CMakeLists.txt cmake: Enable WITH_MINIMAL_EXAMPLES by default 2021-11-11 11:52:46 +00:00
policy.json examples: move existing to m-e-lowlevel and start repoulating m-e with SS 2021-10-08 09:49:05 +01:00
README.md examples: move existing to m-e-lowlevel and start repoulating m-e with SS 2021-10-08 09:49:05 +01:00
ss-s3-main.c examples: move existing to m-e-lowlevel and start repoulating m-e with SS 2021-10-08 09:49:05 +01:00
ss-s3-put.h examples: move existing to m-e-lowlevel and start repoulating m-e with SS 2021-10-08 09:49:05 +01:00
ss-s3-ss.c examples: move existing to m-e-lowlevel and start repoulating m-e with SS 2021-10-08 09:49:05 +01:00
static_policy.h examples: move existing to m-e-lowlevel and start repoulating m-e with SS 2021-10-08 09:49:05 +01:00

lws minimal secure streams sigv4

The application put a test file to AWS S3, using sigv4 auth.

It does it using Secure Streams... the streamtype is "s3PutObj", along with main are in ss-s3-main.c

The handler for state changes and payloads for "s3PutObj" is in ss-s3-ss.c

metadata

"aws_region" and "aws_service" are configured through metadata. Also, at least "x-amz-content-sha256:" and ""x-amz-date:" headers need to be in metadata.

credentials

credentials are read from ~/.aws/credentials, make sure you have valid keyid and key. One need to call lws_ss_sigv4_set_aws_key() to plug in aws credentials into Secure Streams and the index need to be match of the "blob_index" in entry of "auth" the policy. In addition, you need to change the S3 bucket name to your own, as bucket name is unique globally in S3.

build

 $ cmake . && make

usage

[2020/12/19 15:25:06:9763] U: LWS minimal secure streams sigv4
[2020/12/19 15:25:07:0768] U: ss_s3_state: LWSSSCS_CREATING, ord 0x0
[2020/12/19 15:25:07:0769] U: ss_s3_state: LWSSSCS_POLL, ord 0x0
[2020/12/19 15:25:07:0770] U: ss_s3_state: LWSSSCS_CONNECTING, ord 0x0
[2020/12/19 15:25:07:2317] U: SS / TX Payload
[2020/12/19 15:25:07:2317] U: SS / TX Payload Total = 1024, Pos = 0
[2020/12/19 15:25:07:3267] U: ss_s3_state: LWSSSCS_CONNECTED, ord 0x0
[2020/12/19 15:25:07:3267] U: ss_s3_state: LWSSSCS_QOS_ACK_REMOTE, ord 0x0
[2020/12/19 15:25:07:3267] U: ss_s3_state: LWSSSCS_DISCONNECTED, ord 0x0
[2020/12/19 15:25:07:3268] U: ss_s3_state: LWSSSCS_DESTROYING, ord 0x0
[2020/12/19 15:25:07:3269] U: Completed: OK