azcertcache

package module
v0.0.0-...-7020cbf Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 9 Imported by: 0

README

GoDoc Go Report Card

azcertcache

Azure Blob Storage cache for acme/autocert written in Go.

Example

containerName := "autocertcache"
cache, err := azcertcache.New("<account name>", "<account key>", containerName)
if err != nil {
  // Handle error
}

m := autocert.Manager{
  Prompt:     autocert.AcceptTOS,
  Cache:      cache,
}

s := &http.Server{
  Addr:      ":https",
  TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},
}

s.ListenAndServeTLS("", "")

Performance

This is just a reminder that autocert has an internal in-memory cache that is used before quering this long-term cache. So you don't need to worry about your Azure Blob Storage instance being hit many times just to get the same certificate. It should only do once per process+key.

Thanks

Inspired by https://github.com/danilobuerger/autocert-s3-cache

License

MIT

Documentation

Overview

Package azcertcache implements an autocert.Cache to store certificate data within an Azure Blob Storage container

See https://godoc.org/golang.org/x/crypto/acme/autocert

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyContainerName = errors.New("containerName must not be empty")

ErrEmptyContainerName is returned when given container name is empty

Functions

This section is empty.

Types

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache provides an Azure Blob Storage backend to the autocert cache.

func New

func New(accountName, accountKey, containerName string) (*Cache, error)

New creates an cache instance that can be used with autocert.Cache. It returns any errors that could happen while connecting to Azure Blob Storage.

func NewWithEndpoint

func NewWithEndpoint(accountName, accountKey, containerName, endpointURL string) (*Cache, error)

NewWithEndpoint creates an cache instance that can be used with autocert.Cache. Endpoint can be used to target a different environment that is not Azure It returns any errors that could happen while connecting to Azure Blob Storage.

func (*Cache) CreateContainer

func (c *Cache) CreateContainer(ctx context.Context) error

CreateContainer based on current configured container

func (*Cache) Delete

func (c *Cache) Delete(ctx context.Context, key string) error

Delete removes a certificate data from the cache under the specified key. If there's no such key in the cache, Delete returns nil.

func (*Cache) DeleteContainer

func (c *Cache) DeleteContainer(ctx context.Context) error

DeleteContainer based on current configured container

func (*Cache) Get

func (c *Cache) Get(ctx context.Context, key string) ([]byte, error)

Get returns a certificate data for the specified key. If there's no such key, Get returns ErrCacheMiss.

func (*Cache) Put

func (c *Cache) Put(ctx context.Context, key string, data []byte) error

Put stores the data in the cache under the specified key.

Jump to

Keyboard shortcuts

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