httpsig

package
v3.15.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package httpsig implements the OCM profile of RFC 9421 HTTP Message Signatures.

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsigned = errors.New("the request has no OCM signature")

ErrUnsigned is returned by Verify for a request without an OCM signature.

Functions

func Verify

func Verify(r *http.Request, body []byte, endpoint string, jwks func() ([]byte, error)) error

Verify checks the OCM signature of r. body is the request body, which r no longer holds. endpoint is the public URL of this server. If it is empty, Verify takes the scheme and the host from r. jwks returns the JWK Set of the signer. Verify calls it only for a signed request, thus an unsigned request does not cause a fetch.

Types

type Key

type Key struct {
	// ID is the keyid of the signatures and the kid of the published key.
	ID string
	// contains filtered or unexported fields
}

Key is the private key that this server uses to sign OCM requests.

func LoadKey

func LoadKey(path string) (*Key, error)

LoadKey reads an Ed25519 private key from a PKCS#8 PEM file, such as the output of `openssl genpkey -algorithm ed25519`.

func (*Key) JWKS

func (k *Key) JWKS() ([]byte, error)

JWKS returns the JWK Set that publishes the public part of k.

func (*Key) Sign

func (k *Key) Sign(r *http.Request, body []byte) error

Sign adds an OCM signature to r. body must be the bytes that r sends.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址