Documentation
¶
Index ¶
- Constants
- Variables
- func CertificateValid(ca ssh.PublicKey, pub ssh.PublicKey, cert *ssh.Certificate) error
- func RenewalDue(c *ssh.Certificate, at float64, now time.Time) bool
- type BaseCertificate
- type Certificate
- type HostCertificate
- type Option
- type Renewable
- type RenewableWaiter
- type Requestable
- type RequestableWaiter
- type Storage
- type UserCertificate
- type Waiter
Constants ¶
const DefaultHostCertificateLifetime = (time.Hour * 24) * 30
const DefaultUserCertificateLifetime = time.Hour * 24
Variables ¶
var ( ErrAddingToAgent = errors.New("could not add to agent") ErrCertificateMismatch = errors.New("certificate did not match private key") ErrCertificateNotFound = errors.New("no certificate found") ErrCertificateNotValid = errors.New("certificate validity not ok") ErrKeyNotFound = errors.New("no key private key found") ErrNoAuthHandlerAvailable = errors.New("no auth handler was available") ErrNotImplemented = errors.New("method not implemented") ErrSignerNotFound = errors.New("no signer found") ErrUnexpectedCertificateAuthority = errors.New("certificate was not issued by the CA") ErrUnexpectedResponse = errors.New("unexpected response from CA") )
var ( ErrInitialRequestFailed = errors.New("initial certificate request failed") ErrNotRunning = errors.New("renewal ticker not running") )
var (
ErrEmptyPrincipalsList = errors.New("principals list was empty")
)
Functions ¶
func CertificateValid ¶
Helper function to validate a certificate. This checks that the certificate is not expired, was issued by the expected CA and that the certificate is for the public key of the private key it will be used with.
func RenewalDue ¶
RenewalDue reports whether the fraction at (between 0 and 1) of the certificate's validity period, from ValidAfter to ValidBefore, has passed at now. Expired certificates are always due and certificates that never expire are never due.
Types ¶
type BaseCertificate ¶
type BaseCertificate struct {
// contains filtered or unexported fields
}
func (*BaseCertificate) Store ¶
func (base *BaseCertificate) Store() Storage
type Certificate ¶
type Certificate interface {
Store() Storage
}
type HostCertificate ¶
type HostCertificate struct {
*BaseCertificate
AuthHandler auth.Handler
Lifetime time.Duration
Principals []string
}
func NewHostCertificate ¶
func NewHostCertificate(server string, store Storage, opts ...Option) (*HostCertificate, error)
func (*HostCertificate) Renew ¶
func (h *HostCertificate) Renew() error
Renew renews the existing host certificate. See HostCertificate.RenewContext.
func (*HostCertificate) RenewContext ¶
func (h *HostCertificate) RenewContext(ctx context.Context) error
RenewContext renews the existing host certificate using proof of possession of the private key, saving the renewed certificate to the store. Cancelling ctx aborts the request to the CA.
func (*HostCertificate) Request ¶
func (h *HostCertificate) Request() error
Request requests a new host certificate. See HostCertificate.RequestContext.
func (*HostCertificate) RequestContext ¶
func (h *HostCertificate) RequestContext(ctx context.Context) error
RequestContext authenticates using the AuthHandler and requests a new host certificate for Principals from the CA, saving it to the store. Cancelling ctx stops waiting for authentication and aborts the request to the CA.
type Renewable ¶
type Renewable interface {
Requestable
Renew() error
RenewContext(ctx context.Context) error
}
type RenewableWaiter ¶
type Requestable ¶
type Requestable interface {
Certificate
Request() error
RequestContext(ctx context.Context) error
}
type RequestableWaiter ¶
type RequestableWaiter interface {
Requestable
Waiter
}
type Storage ¶
type Storage interface {
AddToAgent() error
Certificate() (*ssh.Certificate, error)
CertificateBytes() ([]byte, error)
GeneratePrivateKey() error
HasCertificate() bool
HasPrivateKey() bool
PrivateKey() (crypto.PrivateKey, error)
PrivateKeyBytes() ([]byte, error)
PublicKey() (ssh.PublicKey, error)
PublicKeyBytes() ([]byte, error)
SaveCertificate(*ssh.Certificate) error
Signer() (ssh.Signer, error)
}
type UserCertificate ¶
type UserCertificate struct {
*BaseCertificate
AuthHandler auth.Handler
Lifetime time.Duration
}
func NewUserCertificate ¶
func NewUserCertificate(server string, store Storage, opts ...Option) (*UserCertificate, error)
func (*UserCertificate) Request ¶
func (u *UserCertificate) Request() error
Request requests a new user certificate. See UserCertificate.RequestContext.
func (*UserCertificate) RequestContext ¶
func (u *UserCertificate) RequestContext(ctx context.Context) error
RequestContext authenticates using the AuthHandler and requests a new user certificate from the CA, saving it to the store. Cancelling ctx stops waiting for authentication and aborts the request to the CA.