mirror of
https://github.com/rustfs/rustfs.git
synced 2026-01-17 01:30:33 +00:00
Resolving the issue of encryption parameters not being stored.
This commit is contained in:
28
scripts/generate-sse-keys.ps1
Normal file
28
scripts/generate-sse-keys.ps1
Normal file
@@ -0,0 +1,28 @@
|
||||
# Generate SSE encryption key (32 bytes base64 encoded)
|
||||
# For testing with __RUSTFS_SSE_SIMPLE_CMK environment variable
|
||||
# Usage: .\generate-sse-keys.ps1
|
||||
|
||||
# Function to generate a random 256-bit key and encode it in base64
|
||||
function Generate-Base64Key {
|
||||
# Generate 32 bytes (256 bits) of random data
|
||||
$bytes = New-Object byte[] 32
|
||||
$rng = [System.Security.Cryptography.RandomNumberGenerator]::Create()
|
||||
$rng.GetBytes($bytes)
|
||||
$rng.Dispose()
|
||||
|
||||
# Convert to base64
|
||||
return [Convert]::ToBase64String($bytes)
|
||||
}
|
||||
|
||||
# Generate key
|
||||
$base64Key = Generate-Base64Key
|
||||
|
||||
# Output result
|
||||
Write-Host ""
|
||||
Write-Host "Generated SSE encryption key (32 bytes, base64 encoded):" -ForegroundColor Green
|
||||
Write-Host ""
|
||||
Write-Host $base64Key -ForegroundColor Yellow
|
||||
Write-Host ""
|
||||
Write-Host "You can use this in your environment variable:" -ForegroundColor Cyan
|
||||
Write-Host "`$env:__RUSTFS_SSE_SIMPLE_CMK=`"$base64Key`"" -ForegroundColor White
|
||||
Write-Host ""
|
||||
24
scripts/generate-sse-keys.sh
Normal file
24
scripts/generate-sse-keys.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/bin/bash
|
||||
# Generate SSE encryption key (32 bytes base64 encoded)
|
||||
# For testing with __RUSTFS_SSE_SIMPLE_CMK environment variable
|
||||
# Usage: ./generate-sse-keys.sh
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Function to generate a random 256-bit key and encode it in base64
|
||||
generate_base64_key() {
|
||||
# Generate 32 bytes (256 bits) of random data and base64 encode it
|
||||
openssl rand -base64 32 | tr -d '\n'
|
||||
}
|
||||
|
||||
# Generate key
|
||||
base64_key=$(generate_base64_key)
|
||||
|
||||
# Output result
|
||||
echo "Generated SSE encryption key (32 bytes, base64 encoded):"
|
||||
echo ""
|
||||
echo "$base64_key"
|
||||
echo ""
|
||||
echo "You can use this in your environment variable:"
|
||||
echo "export __RUSTFS_SSE_SIMPLE_CMK=\"$base64_key\""
|
||||
|
||||
Reference in New Issue
Block a user