Documentation ¶
Index ¶
- Constants
- Variables
- func GetOCSPForCert(bundle []byte) ([]byte, *ocsp.Response, error)
- func GetPEMCertExpiration(cert []byte) (time.Time, error)
- type CertificateResource
- type Client
- func (c *Client) AgreeToTOS() error
- func (c *Client) ExcludeChallenges(challenges []string)
- func (c *Client) ObtainCertificate(domains []string, bundle bool, privKey crypto.PrivateKey) (CertificateResource, map[string]error)
- func (c *Client) Register() (*RegistrationResource, error)
- func (c *Client) RenewCertificate(cert CertificateResource, bundle bool) (CertificateResource, error)
- func (c *Client) RevokeCertificate(certificate []byte) error
- func (c *Client) SetHTTPAddress(iface string) error
- func (c *Client) SetTLSAddress(iface string) error
- type Registration
- type RegistrationResource
- type RemoteError
- type TOSError
- type User
Constants ¶
const ( // OCSPGood means that the certificate is valid. OCSPGood = ocsp.Good // OCSPRevoked means that the certificate has been deliberately revoked. OCSPRevoked = ocsp.Revoked // OCSPUnknown means that the OCSP responder doesn't know about the certificate. OCSPUnknown = ocsp.Unknown // OCSPServerFailed means that the OCSP responder failed to process the request. OCSPServerFailed = ocsp.ServerFailed )
Variables ¶
var ( // Logger is an optional custom logger. Logger *log.Logger )
var UserAgent string
UserAgent, if non-empty, will be tacked onto the User-Agent string in requests.
Functions ¶
func GetOCSPForCert ¶
GetOCSPForCert takes a PEM encoded cert or cert bundle returning the raw OCSP response, the parsed response, and an error, if any. The returned []byte can be passed directly into the OCSPStaple property of a tls.Certificate. If the bundle only contains the issued certificate, this function will try to get the issuer certificate from the IssuingCertificateURL in the certificate. If the []byte and/or ocsp.Response return values are nil, the OCSP status may be assumed OCSPUnknown.
Types ¶
type CertificateResource ¶
type CertificateResource struct { Domain string `json:"domain"` CertURL string `json:"certUrl"` CertStableURL string `json:"certStableUrl"` PrivateKey []byte `json:"-"` Certificate []byte `json:"-"` }
CertificateResource represents a CA issued certificate. PrivateKey and Certificate are both already PEM encoded and can be directly written to disk. Certificate may be a certificate bundle, depending on the options supplied to create it.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the user-friendy way to ACME
func NewClient ¶
NewClient creates a new ACME client on behalf of the user. The client will depend on the ACME directory located at caDirURL for the rest of its actions. It will generate private keys for certificates of size keyBits.
func (*Client) AgreeToTOS ¶
AgreeToTOS updates the Client registration and sends the agreement to the server.
func (*Client) ExcludeChallenges ¶
ExcludeChallenges explicitly removes challenges from the pool for solving.
func (*Client) ObtainCertificate ¶
func (c *Client) ObtainCertificate(domains []string, bundle bool, privKey crypto.PrivateKey) (CertificateResource, map[string]error)
ObtainCertificate tries to obtain a single certificate using all domains passed into it. The first domain in domains is used for the CommonName field of the certificate, all other domains are added using the Subject Alternate Names extension. A new private key is generated for every invocation of this function. If you do not want that you can supply your own private key in the privKey parameter. If this parameter is non-nil it will be used instead of generating a new one. If bundle is true, the []byte contains both the issuer certificate and your issued certificate as a bundle. This function will never return a partial certificate. If one domain in the list fails, the whole certificate will fail.
func (*Client) Register ¶
func (c *Client) Register() (*RegistrationResource, error)
Register the current account to the ACME server.
func (*Client) RenewCertificate ¶
func (c *Client) RenewCertificate(cert CertificateResource, bundle bool) (CertificateResource, error)
RenewCertificate takes a CertificateResource and tries to renew the certificate. If the renewal process succeeds, the new certificate will ge returned in a new CertResource. Please be aware that this function will return a new certificate in ANY case that is not an error. If the server does not provide us with a new cert on a GET request to the CertURL this function will start a new-cert flow where a new certificate gets generated. If bundle is true, the []byte contains both the issuer certificate and your issued certificate as a bundle. For private key reuse the PrivateKey property of the passed in CertificateResource should be non-nil.
func (*Client) RevokeCertificate ¶
RevokeCertificate takes a PEM encoded certificate or bundle and tries to revoke it at the CA.
func (*Client) SetHTTPAddress ¶
SetHTTPAddress specifies a custom interface:port to be used for HTTP based challenges. If this option is not used, the default port 80 and all interfaces will be used. To only specify a port and no interface use the ":port" notation.
func (*Client) SetTLSAddress ¶
SetTLSAddress specifies a custom interface:port to be used for TLS based challenges. If this option is not used, the default port 443 and all interfaces will be used. To only specify a port and no interface use the ":port" notation.
type Registration ¶
type Registration struct { Resource string `json:"resource,omitempty"` ID int `json:"id"` Key struct { Kty string `json:"kty"` N string `json:"n"` E string `json:"e"` } `json:"key"` Contact []string `json:"contact"` Agreement string `json:"agreement,omitempty"` Authorizations string `json:"authorizations,omitempty"` Certificates string `json:"certificates,omitempty"` }
Registration is returned by the ACME server after the registration The client implementation should save this registration somewhere.
type RegistrationResource ¶
type RegistrationResource struct { Body Registration `json:"body,omitempty"` URI string `json:"uri,omitempty"` NewAuthzURL string `json:"new_authzr_uri,omitempty"` TosURL string `json:"terms_of_service,omitempty"` }
RegistrationResource represents all important informations about a registration of which the client needs to keep track itself.
type RemoteError ¶
type RemoteError struct { StatusCode int `json:"status,omitempty"` Type string `json:"type"` Detail string `json:"detail"` }
RemoteError is the base type for all errors specific to the ACME protocol.
func (RemoteError) Error ¶
func (e RemoteError) Error() string
type TOSError ¶
type TOSError struct {
RemoteError
}
TOSError represents the error which is returned if the user needs to accept the TOS. TODO: include the new TOS url if we can somehow obtain it.
type User ¶
type User interface { GetEmail() string GetRegistration() *RegistrationResource GetPrivateKey() *rsa.PrivateKey }
User interface is to be implemented by users of this library. It is used by the client type to get user specific information.