Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,21 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.7
check-latest: true
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v6
- name: 'Set up Go'
uses: actions/setup-go@v6
with:
go-version-file: 'kms/go.mod'
- name: Build
run: |
go build ./kms ./kes
go vet ./kms ./kes
- name: Lint
uses: golangci/golangci-lint-action@v3
uses: golangci/golangci-lint-action@v7
with:
version: latest
args: --config ./.golangci.yml ./kms ./kes
version: v2.11.3
args: --config ./.golangci.yml --timeout=5m ./kms ./kes
test:
name: Test ${{ matrix.os }}
needs: Build
Expand All @@ -37,33 +36,34 @@ jobs:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.7
check-latest: true
- name: Check out code
uses: actions/checkout@v3
uses: actions/checkout@v6
- name: 'Set up Go'
uses: actions/setup-go@v6
with:
go-version-file: 'kms/go.mod'
- name: Test
run: |
go test ./kms ./kes

vulncheck:
name: Vulncheck
needs: Build
needs: build
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v3
- uses: actions/setup-go@v3
uses: actions/checkout@v6
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: 1.22.7
check-latest: true
go-version-file: 'kms/go.mod'
- name: Get govulncheck
run: go install golang.org/x/vuln/cmd/govulncheck@latest
shell: bash
- name: Run govulncheck
env:
GODEBUG: toolchaintrace=1
run: |
govulncheck -C ./kms
govulncheck -C ./kes
govulncheck -C ./kms ./...
govulncheck -C ./kes ./...
shell: bash
39 changes: 18 additions & 21 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
linters-settings:
golint:
min-confidence: 0

misspell:
locale: US

staticcheck:
checks: ["all"]
version: "2"

linters:
disable-all: true
default: none
enable:
- typecheck
- goimports
- misspell
- staticcheck
- govet
- revive
- ineffassign
- gosimple
- unused
- unparam
- prealloc
- unconvert
- gofumpt

issues:
exclude-use-default: false
exclude:
- "var-naming: don't use ALL_CAPS in Go names; use CamelCase"
- "package-comments: should have a package comment"
settings:
staticcheck:
checks: ["all", "-SA1019", "-ST1000", "-ST1003", "-QF1008"]

revive:
rules:
- name: var-naming
disabled: true

misspell:
locale: US

service:
golangci-lint-version: 1.57.2 # use the fixed version to not introduce new linters unexpectedly
formatters:
enable:
- gofumpt
- goimports
2 changes: 1 addition & 1 deletion go.work
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
go 1.24
go 1.25.0

use (
./kes
Expand Down
2 changes: 1 addition & 1 deletion kes/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ var _ net.Error = (*ConnError)(nil) // compiler check
// Error returns the string representation of the ConnError.
func (c *ConnError) Error() string { return fmt.Sprintf("kes: connection error: %v", c.Err) }

// Unwarp returns the underlying connection error.
// Unwrap returns the underlying connection error.
func (c *ConnError) Unwrap() error { return c.Err }

// Timeout reports whether the error is caused
Expand Down
2 changes: 1 addition & 1 deletion kes/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/minio/kms-go/kes

go 1.24
go 1.25

require (
aead.dev/mem v0.2.0
Expand Down
2 changes: 2 additions & 0 deletions kes/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ type requestOption func(*http.Request)

// withHeader returns a requestOption that sets the given
// key-value pair as HTTP header.
//
//nolint:unparam
func withHeader(key, value string) requestOption {
return func(req *http.Request) {
req.Header.Set(key, value)
Expand Down
2 changes: 1 addition & 1 deletion kms/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ type Config struct {
//
// When providing an API key, no TLS.Certificates
// or TLS.GetClientCertificate must be present.
APIKey mtls.PrivateKey
APIKey *mtls.PrivateKey

// Optional TLS configuration.
//
Expand Down
8 changes: 3 additions & 5 deletions kms/go.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
module github.com/minio/kms-go/kms

go 1.24
go 1.25

require (
aead.dev/mem v0.2.0
aead.dev/mtls v0.2.1
google.golang.org/protobuf v1.33.0
aead.dev/mtls v0.4.0
google.golang.org/protobuf v1.36.11
)

require github.com/google/go-cmp v0.6.0 // indirect

tool google.golang.org/protobuf/cmd/protoc-gen-go
12 changes: 6 additions & 6 deletions kms/go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
aead.dev/mem v0.2.0 h1:ufgkESS9+lHV/GUjxgc2ObF43FLZGSemh+W+y27QFMI=
aead.dev/mem v0.2.0/go.mod h1:4qj+sh8fjDhlvne9gm/ZaMRIX9EkmDrKOLwmyDtoMWM=
aead.dev/mtls v0.2.1 h1:47NHWciMvrmEhlkpnis8/RGEa9HR9gcbDPfcArG+Yqs=
aead.dev/mtls v0.2.1/go.mod h1:rZvRApIcPkCNu2AgpFoaMxKBee/XVkKs7wEuYgqLI3Q=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
aead.dev/mtls v0.4.0 h1:s+nuIKH0ZZIZ1RsfOjYVx0q2OcfKFKS3UaJGngrTLFY=
aead.dev/mtls v0.4.0/go.mod h1:ZuSTM2+kagQsjaWoHn7yTU36MAaEaH/5Aq5XR4uYMk4=
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
google.golang.org/protobuf v1.36.11 h1:fV6ZwhNocDyBLK0dj+fg8ektcVegBBuEolpbTQyBNVE=
google.golang.org/protobuf v1.36.11/go.mod h1:HTf+CrKn2C3g5S8VImy6tdcUvCska2kB7j23XfzDpco=
31 changes: 8 additions & 23 deletions kms/identity.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ import (
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
"errors"
"math/big"
"strconv"
"time"

Expand Down Expand Up @@ -79,16 +77,9 @@ func (p Privilege) String() string {
//
// The template may be nil. In such a case the returned certificate
// is generated using a default template and valid for 90 days.
func GenerateCertificate(key mtls.PrivateKey, template *x509.Certificate) (tls.Certificate, error) {
func GenerateCertificate(key mtls.Signer, template *x509.Certificate) (tls.Certificate, error) {
if template == nil {
serialNumberLimit := new(big.Int).Lsh(big.NewInt(1), 128)
serialNumber, err := rand.Int(rand.Reader, serialNumberLimit)
if err != nil {
return tls.Certificate{}, err
}

template = &x509.Certificate{
SerialNumber: serialNumber,
Subject: pkix.Name{
CommonName: key.Identity().String(),
},
Expand All @@ -102,23 +93,17 @@ func GenerateCertificate(key mtls.PrivateKey, template *x509.Certificate) (tls.C
}
}

certDER, err := x509.CreateCertificate(rand.Reader, template, template, key.Public(), key.Private())
if err != nil {
return tls.Certificate{}, err
}
privPKCS8, err := x509.MarshalPKCS8PrivateKey(key.Private())
certDER, err := x509.CreateCertificate(rand.Reader, template, template, key.Public(), key)
if err != nil {
return tls.Certificate{}, err
}
cert, err := tls.X509KeyPair(
pem.EncodeToMemory(&pem.Block{Type: "CERTIFICATE", Bytes: certDER}),
pem.EncodeToMemory(&pem.Block{Type: "PRIVATE KEY", Bytes: privPKCS8}),
)
leaf, err := x509.ParseCertificate(certDER)
if err != nil {
return tls.Certificate{}, err
}
if cert.Leaf == nil {
cert.Leaf, _ = x509.ParseCertificate(cert.Certificate[0])
}
return cert, nil
return tls.Certificate{
Certificate: [][]byte{certDER},
PrivateKey: key,
Leaf: leaf,
}, nil
}
Loading