acmeclient

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2019 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PebbleConfigJSON contains the configration of Pebble.
	PebbleConfigJSON = "testdata/pebble-config.json"
	// DNSPort is the port pebble uses for DNS queries.
	DNSPort = "8053"
)

Variables

This section is empty.

Functions

func InitializeLego

func InitializeLego(logger log.Logger)

InitializeLego initializes the lego library.

Lego uses a global variable to store a logger. In order to use a different loger this variable has to be set. The InitializeLego function uses a sync.Once ensures that the Logger is set only once, no matter how often the function is called. However, direct access to leoglog.Logger cannot be protected.

func NewChallengeServer

func NewChallengeServer(t *testing.T, solver *HTTP01Solver, port int) *httptest.Server

NewChallengeServer creates an httptest.Server which uses the handler to serve HTTP01 challenges.

Types

type Client

type Client struct {
	DirectoryURL string
	HTTP01Solver HTTP01Solver
}

Client is an ACME protocol client capable of obtaining and renewing certificates.

func (*Client) CreateAccount

func (c *Client) CreateAccount(accountKey crypto.PrivateKey, email string) (string, error)

CreateAccount creates a new ACME account for the accountKey.

If email is not empty it is used as the contact address for the new account.

func (*Client) ObtainCertificate

func (c *Client) ObtainCertificate(req acme.CertificateRequest) (*acme.CertificateInfo, error)

ObtainCertificate obtains a new certificate from the remote ACME server.

type HTTP01Solver

type HTTP01Solver struct {
	Logger log.Logger
	// contains filtered or unexported fields
}

HTTP01Solver is a custom challenge provider for the HTTP01 challenge.

In contrast to the default HTTP01 challenge provider shipped with lego it does not start a web-server but instead provides a handle challenge method which can be used in an http.Handler or http.HandlerFunc.

HTTP01Solver is safe for concurrent access by multiple Go routines.

The methods Present and CleanUp are intended for use by lego and should not be called directly.

The zero value of HTTP01Solver is fully functional.

func (*HTTP01Solver) CleanUp

func (p *HTTP01Solver) CleanUp(domain, token, keyAuth string) error

CleanUp removes the solution for a HTTP01 challenge from the HTTP01Solver.

This method is intended to be used by lego and should not be called directly.

func (*HTTP01Solver) Handler

func (p *HTTP01Solver) Handler(extractParams func(*http.Request) map[string]string) http.Handler

Handler creates an http.Handler serving the actual HTTP01 challenge.

The extractParams function is used to extract the required parameters from the request. It must return a map containing the keys domain and token, or nil if the map cannot be constructed.

func (*HTTP01Solver) Present

func (p *HTTP01Solver) Present(domain, token, keyAuth string) error

Present registers a solution for a HTTP01 challenge with the HTTP01Solver.

This method is intended to be used by lego and should not be called directly.

type TestFixture

type TestFixture struct {
	Pebble *testsupport.Pebble
	Client *Client
}

TestFixture wraps a Client suitable for testing.

func NewTestFixture

func NewTestFixture(t *testing.T) (TestFixture, func())

NewTestFixture creates a new test fixture.

type User

type User struct {
	Email        string
	Registration *registration.Resource
	PrivateKey   crypto.PrivateKey
}

User represents an user of the ACME certificate authority.

It implements https://godoc.org/github.com/go-acme/lego/registration#User.

func (*User) GetEmail

func (u *User) GetEmail() string

GetEmail returns the users email.

func (*User) GetPrivateKey

func (u *User) GetPrivateKey() crypto.PrivateKey

GetPrivateKey returns the users private key.

func (*User) GetRegistration

func (u *User) GetRegistration() *registration.Resource

GetRegistration returns the users registration.

func (*User) Register

func (u *User) Register(lc *lego.Client) error

Register creates a new reqistration with the ACME certificate authority and sets u.Registration. Does nothing if u.Registration is already set to some value.

Jump to

Keyboard shortcuts

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