mirror of
https://github.com/versity/versitygw.git
synced 2026-01-03 10:35:15 +00:00
The `openssl`/`curl` command generator script in `rest_scripts` supports both unsigned streaming payload trailers and signed streaming requests. This update adds support for signed streaming requests with trailers (`STREAMING-AWS4-HMAC-SHA256-PAYLOAD-TRAILER`). **Usage** The script generates an OpenSSL command file, which is then used to send the request. Example: ```bash go run tests/rest_scripts/generateCommand.go \ --awsAccessKeyId access \ --awsSecretAccessKey secret \ --client openssl \ --commandType putObject \ --bucketName test \ --payload "hello" \ --payloadType STREAMING-UNSIGNED-PAYLOAD-TRAILER \ --chunkSize 8192 \ --objectKey obj \ --filePath req.txt \ --checksumType crc64nvme ``` You can then send the request with: ```bash openssl s_client -connect 127.0.0.1:7070 -ign_eof < req.txt > response.raw ```
31 lines
748 B
Go
31 lines
748 B
Go
package command
|
|
|
|
import (
|
|
"encoding/hex"
|
|
"strings"
|
|
|
|
"github.com/versity/versitygw/tests/rest_scripts/logger"
|
|
)
|
|
|
|
type PayloadChunkedAWS struct {
|
|
*PayloadChunked
|
|
serviceString string
|
|
currentDateTime string
|
|
yyyymmdd string
|
|
lastSignature string
|
|
emptyByteSignature string
|
|
signingKey []byte
|
|
}
|
|
|
|
func (c *PayloadChunkedAWS) getChunkedSTSSignature(chunkSignature string) string {
|
|
request := strings.Join([]string{"AWS4-HMAC-SHA256-PAYLOAD",
|
|
c.currentDateTime,
|
|
c.serviceString,
|
|
c.lastSignature,
|
|
c.emptyByteSignature,
|
|
chunkSignature}, "\n")
|
|
logger.PrintDebug("request: %s", request)
|
|
canonicalRequestHashBytes := hmacSHA256(c.signingKey, request)
|
|
return hex.EncodeToString(canonicalRequestHashBytes[:])
|
|
}
|