certbucket

package module
v0.0.0-...-dc72ea0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2017 License: MIT Imports: 5 Imported by: 0

README

certbucket

Certbucket implements acme/autocert Cache using a bucket on Google storage. If the bucket does not exist, it will be created.

Usage

	cache, err := certbucket.New("your-project-id", "cache-bucket-name")
	if err != nil {
		return err
	} 

	m := autocert.Manager{
		Cache:      cache,
		Prompt:     autocert.AcceptTOS,
		HostPolicy: autocert.HostWhitelist("example.com"),
	}

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

	log.Fatal(s.ListenAndServeTLS("", ""))

Testing

Before running tests make sure that your Google Cloud SDK is installed and configured. Set GOOGLE_PROJECT_ID environment variable.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is an adapter that is used to satisfy autocert Cache interface. Under the hood Storage Bucket is used to store certificate.

func New

func New(projectID, bucketName string) (*Cache, error)

New creates new certificate cache storage in Google Cloud Storage bucket. If bucket is not there it will be created.

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) 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 autocert.ErrCacheMiss.

func (*Cache) Put

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

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

Jump to

Keyboard shortcuts

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