Skip to content
Open
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
6 changes: 6 additions & 0 deletions cmd/cosign/cli/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,12 @@ race conditions or (worse) malicious tampering.
# sign a container image with a key, attaching a certificate and certificate chain
cosign sign --key cosign.key --cert cosign.crt --cert-chain chain.crt <IMAGE DIGEST>

# sign a container image with a key, attaching a certificate and certificate chain from a URL
cosign sign --key cosign.key --cert https://example.com/cert --cert-chain https://example.com/cert-chain <IMAGE DIGEST>

# sign a container image with a key, attaching a certificate and certificate chain from an environment variable
cosign sign --key cosign.key --cert https://example.com/cert --cert-chain https://example.com/cert-chain <IMAGE DIGEST>

# sign a container in a registry which does not fully support OCI media types
COSIGN_DOCKER_MEDIA_TYPES=1 cosign sign --key cosign.key legacy-registry.example.com/my/image@<DIGEST>

Expand Down
5 changes: 3 additions & 2 deletions cmd/cosign/cli/sign/sign.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/sigstore/cosign/v2/internal/pkg/cosign/tsa"
"github.com/sigstore/cosign/v2/internal/pkg/cosign/tsa/client"
"github.com/sigstore/cosign/v2/internal/ui"
"github.com/sigstore/cosign/v2/pkg/blob"
"github.com/sigstore/cosign/v2/pkg/cosign"
"github.com/sigstore/cosign/v2/pkg/cosign/pivkey"
"github.com/sigstore/cosign/v2/pkg/cosign/pkcs11key"
Expand Down Expand Up @@ -434,7 +435,7 @@ func signerFromKeyRef(ctx context.Context, certPath, certChainPath, keyRef strin
// Handle --cert flag
if certPath != "" {
// Allow both DER and PEM encoding
certBytes, err := os.ReadFile(certPath)
certBytes, err := blob.LoadFileOrURL(certPath)
if err != nil {
return nil, fmt.Errorf("read certificate: %w", err)
}
Expand Down Expand Up @@ -476,7 +477,7 @@ func signerFromKeyRef(ctx context.Context, certPath, certChainPath, keyRef strin

// Handle --cert-chain flag
// Accept only PEM encoded certificate chain
certChainBytes, err := os.ReadFile(certChainPath)
certChainBytes, err := blob.LoadFileOrURL(certChainPath)
if err != nil {
return nil, fmt.Errorf("reading certificate chain from path: %w", err)
}
Expand Down