static int s_initialize_signing_config()

in native/src/signing.c [111:170]


static int s_initialize_signing_config(
    struct aws_signing_config_aws *config,
    struct aws_signing_config_native *dotnet_config,
    struct aws_dotnet_signing_callback_state *callback_state) {

    struct aws_allocator *allocator = aws_dotnet_get_allocator();

    config->config_type = AWS_SIGNING_CONFIG_AWS;
    config->algorithm = dotnet_config->algorithm;
    config->signature_type = dotnet_config->signature_type;

    if (dotnet_config->region != NULL) {
        callback_state->region = aws_string_new_from_c_str(allocator, dotnet_config->region);
        config->region = aws_byte_cursor_from_string(callback_state->region);
    }

    if (dotnet_config->service != NULL) {
        callback_state->service = aws_string_new_from_c_str(allocator, dotnet_config->service);
        config->service = aws_byte_cursor_from_string(callback_state->service);
    }

    aws_date_time_init_epoch_millis(&config->date, (uint64_t)dotnet_config->milliseconds_since_epoch);

    config->flags.use_double_uri_encode = dotnet_config->use_double_uri_encode != 0;
    config->flags.should_normalize_uri_path = dotnet_config->should_normalize_uri_path != 0;
    config->flags.omit_session_token = dotnet_config->omit_session_token != 0;

    callback_state->credentials = aws_credentials_new(
        allocator,
        s_byte_cursor_from_nullable_c_string(dotnet_config->access_key_id),
        s_byte_cursor_from_nullable_c_string(dotnet_config->secret_access_key),
        s_byte_cursor_from_nullable_c_string(dotnet_config->session_token),
        UINT64_MAX);
    if (callback_state->credentials == NULL) {
        aws_raise_error(AWS_AUTH_SIGNING_INVALID_CONFIGURATION);
        return AWS_OP_ERR;
    }

    config->signed_body_header = dotnet_config->signed_body_header;

    if (dotnet_config->signed_body_value != NULL) {
        callback_state->signed_body_value = aws_string_new_from_c_str(allocator, dotnet_config->signed_body_value);
        if (callback_state->signed_body_value == NULL) {
            return AWS_OP_ERR;
        }

        config->signed_body_value = aws_byte_cursor_from_c_str((const char *)callback_state->signed_body_value->bytes);
    }

    config->credentials = callback_state->credentials;

    config->expiration_in_seconds = dotnet_config->expiration_in_seconds;

    if (dotnet_config->should_sign_header != NULL) {
        config->should_sign_header = s_should_sign_header_adapter;
        config->should_sign_header_ud = callback_state;
    }

    return AWS_OP_SUCCESS;
}