Documentation
¶
Index ¶
- Constants
- Variables
- type CleartextIO
- type IO
- type S3
- func (s3 *S3) CaddyModule() caddy.ModuleInfo
- func (s3 *S3) CertMagicStorage() (certmagic.Storage, error)
- func (s3 *S3) Delete(ctx context.Context, key string) error
- func (s3 *S3) Exists(ctx context.Context, key string) bool
- func (s3 *S3) GoString() string
- func (s3 *S3) List(ctx context.Context, path string, recursive bool) ([]string, error)
- func (s3 *S3) Load(ctx context.Context, key string) ([]byte, error)
- func (s3 *S3) Lock(ctx context.Context, key string) error
- func (s3 *S3) MarshalLogObject(enc zapcore.ObjectEncoder) error
- func (s3 *S3) Provision(ctx caddy.Context) error
- func (s3 *S3) Stat(ctx context.Context, key string) (certmagic.KeyInfo, error)
- func (s3 *S3) Store(ctx context.Context, key string, value []byte) error
- func (s3 *S3) String() string
- func (s3 *S3) Unlock(ctx context.Context, key string) error
- func (s3 *S3) UnmarshalCaddyfile(d *caddyfile.Dispenser) error
- type SecretBoxIO
Constants ¶
const (
// NonceSize is the size of the nonce every encrypted object starts with.
NonceSize = 24
)
Variables ¶
var ( // LockExpiration is how long a lock may go without being refreshed // before other instances treat its holder as gone and take it over. LockExpiration = 2 * time.Minute // LockRefreshInterval is how often a held lock is rewritten to show // its holder is still alive. It must be well below LockExpiration. LockRefreshInterval = 5 * time.Second // LockPollInterval is how often a waiting instance checks the lock. LockPollInterval = 1 * time.Second // LockTimeout bounds how long Lock keeps retrying storage errors. It // does not bound waiting for a live lock: Lock waits for that until the // lock is released, goes stale, or ctx is done. LockTimeout = 15 * time.Second )
var ErrInvalidKey = errors.New("invalid key")
Functions ¶
This section is empty.
Types ¶
type CleartextIO ¶
type CleartextIO struct{}
CleartextIO stores objects as they are.
func (CleartextIO) Seal ¶
func (CleartextIO) Seal(plain []byte) []byte
type IO ¶
type IO interface {
// Seal returns what is stored for plain.
Seal(plain []byte) []byte
// Open returns the data that stored was made from, and whether it took
// an old key to get it.
Open(stored []byte) (plain []byte, underOldKey bool, err error)
}
IO turns the data of an object into what is stored for it, and back.
type S3 ¶
type S3 struct {
Logger *zap.Logger
// S3
Client *s3sdk.Client
Host string `json:"host"`
Endpoint string `json:"endpoint"`
Insecure bool `json:"insecure"`
Bucket string `json:"bucket"`
Region string `json:"region"`
AccessKey string `json:"access_key"`
SecretKey string `json:"secret_key"`
Profile string `json:"profile"`
RoleARN string `json:"role_arn"`
Prefix string `json:"prefix"`
UsePathStyle bool `json:"use_path_style,omitempty"`
// EncryptionKey is optional. If you do not wish to encrypt your certificates and keys inside the S3 bucket, leave it empty.
// It encrypts everything written and is tried first when reading. It is written either as "base64:"
// followed by the base64 of the 32 bytes of the key, or as exactly 32 bytes of text, which are then the
// key as they are. The key is used directly: nothing stretches a weak one.
EncryptionKey string `json:"encryption_key"`
// OldEncryptionKeys are former values of EncryptionKey. They are never used to encrypt; when EncryptionKey
// does not decrypt an object, each of them is tried in order. This makes changing EncryptionKey a rolling
// change: instances that have the new key keep reading what was written under the old ones.
OldEncryptionKeys []string `json:"old_encryption_keys,omitempty"`
// EncryptionKeySSM reads the encryption keys from AWS Systems Manager Parameter Store instead of the
// config: each entry is the name or ARN of a parameter (a SecureString, ideally) whose value is one
// key, written as in EncryptionKey. The first parameter's key encrypts; the others are old keys, tried in order when reading.
// The parameters are read once, when the storage is provisioned, with the region and credentials the
// S3 client uses. It cannot be combined with EncryptionKey.
EncryptionKeySSM []string `json:"encryption_key_ssm,omitempty"`
// EncryptionKeyFile reads the encryption keys from files instead of the config: each entry is the path
// of a file holding one key: its 32 raw bytes, or the key as written in EncryptionKey. The first
// file's key encrypts; the others are old keys, tried in order when reading. The files are read once,
// when the storage is provisioned. It cannot be combined with EncryptionKey or EncryptionKeySSM.
EncryptionKeyFile []string `json:"encryption_key_file,omitempty"`
// contains filtered or unexported fields
}
func (*S3) CaddyModule ¶
func (s3 *S3) CaddyModule() caddy.ModuleInfo
func (*S3) CertMagicStorage ¶
CertMagicStorage converts s to a certmagic.Storage instance.
func (*S3) Delete ¶
Delete removes key and, as certmagic requires of a storage, every key under it: a key can be a "directory" of other keys, such as a site's folder of certificate assets or an ECH config's folder.
func (*S3) List ¶
List returns the keys under path: all of them when recursive, otherwise only the ones directly under it, where a "directory" of further keys is listed once, as a key itself. certmagic and Caddy walk the storage level by level with non-recursive listings.
func (*S3) Lock ¶
Lock acquires the lock for key. It blocks until the lock is free or stale, or ctx is done, and gives up if storage keeps failing for longer than LockTimeout.
func (*S3) MarshalLogObject ¶
func (s3 *S3) MarshalLogObject(enc zapcore.ObjectEncoder) error
MarshalLogObject is what a logger writes for this storage. certmagic logs its storage whole (zap.Any("storage", storage)) on every storage clean; without this method zap falls back to reflection and writes every field, credentials and encryption keys included.
func (*S3) Stat ¶
Stat describes key: an object is a terminal key, and a key that other keys lie under is a "directory".
func (*S3) String ¶
String keeps credentials and encryption keys out of anything that formats the storage with %v, %+v or %s.
type SecretBoxIO ¶
type SecretBoxIO struct {
// contains filtered or unexported fields
}
SecretBoxIO stores an object as a random nonce followed by the object sealed with NaCl secretbox under that nonce.
func NewSecretBoxIO ¶
func NewSecretBoxIO(current [keySize]byte, old ...[keySize]byte) *SecretBoxIO
func (*SecretBoxIO) Seal ¶
func (sb *SecretBoxIO) Seal(plain []byte) []byte