Documentation ¶
Overview ¶
Package autocert
自动生成更新ssl证书 基于acme 简单的http认证方式,可以启动在:http以供challenge时使用
使用 cert := autocert.NewDefault()
cert.RunAndStop() 证书将会保存至fushin-cert目录下
Index ¶
- Constants
- func AutoCert(c *Cert, err error)
- func CleanCertCache() error
- func CreateCertDir() error
- func GeneratePrivateKey() (crypto.PrivateKey, error)
- func GeneratePrivateKeyCustom(curve elliptic.Curve) (crypto.PrivateKey, error)
- func HasCertCache() bool
- func HttpRun() error
- func HttpRunForOnce() error
- func HttpRunWithCtx(ctx context.Context)
- func NewClient(account *Cert) (*lego.Client, error)
- func ObtainDomains(c *lego.Client, domains []string) (*certificate.Resource, error)
- func RegAccount(c *lego.Client) (*registration.Resource, error)
- func RegProvider(c *lego.Client, challenge string) error
- func SaveCert(p string, cert *certificate.Resource) error
- func SetCertCacheDir(p string)
- type Cert
- func (c *Cert) AddDomains(ds []string)
- func (c *Cert) AddRegistration(reg *registration.Resource)
- func (c *Cert) Create() (*certificate.Resource, error)
- func (c *Cert) GetCertPath() string
- func (c *Cert) GetDomains() []string
- func (c *Cert) GetEmail() string
- func (c *Cert) GetPrivateKey() crypto.PrivateKey
- func (c *Cert) GetRegistration() *registration.Resource
- func (c *Cert) Ready() error
- func (c *Cert) Run() (err error)
- func (c *Cert) RunAndStop() error
- func (c *Cert) SetCertPath(p string)
- func (c *Cert) SetChallengePath(p string)
- func (c *Cert) SetKeyType(t string)
- func (c *Cert) SetRenew(t int)
Constants ¶
View Source
const ( CertPath = "fushin-certs" // 存储ssl证书的路径 Renew = 60 * 60 * 24 * 30 )
View Source
const ( RSA2048 string = "RSA-2048" RSA4096 string = "RSA-4096" RSA8192 string = "RSA-8192" EC256 string = "ECDSA-256" EC384 string = "ECDSA-384" )
View Source
const ( PrivateKey = "private.key" // 私钥 Certificate = "fullchain.pem" // 证书 CA = "ca.crt" // CA CSR = "csr" // 全量csr )
Variables ¶
This section is empty.
Functions ¶
func CleanCertCache ¶
func CleanCertCache() error
func CreateCertDir ¶
func CreateCertDir() error
func GeneratePrivateKey ¶
func GeneratePrivateKey() (crypto.PrivateKey, error)
GeneratePrivateKey 生成P256的私钥
func GeneratePrivateKeyCustom ¶
func GeneratePrivateKeyCustom(curve elliptic.Curve) (crypto.PrivateKey, error)
func HasCertCache ¶
func HasCertCache() bool
func HttpRunForOnce ¶
func HttpRunForOnce() error
func HttpRunWithCtx ¶
func ObtainDomains ¶
ObtainDomains 3.注册域名
Types ¶
type Cert ¶
type Cert struct { Email string Registration *registration.Resource KeyType string Challenge string // 质询文件路径 默认拼接$PATH/.well-known/acme-challenge/ // contains filtered or unexported fields }
func NewDefault ¶
func (*Cert) AddDomains ¶
func (*Cert) AddRegistration ¶
func (c *Cert) AddRegistration(reg *registration.Resource)
func (*Cert) GetCertPath ¶
func (*Cert) GetDomains ¶
func (*Cert) GetPrivateKey ¶
func (c *Cert) GetPrivateKey() crypto.PrivateKey
GetPrivateKey returns the private RSA account key.
func (*Cert) GetRegistration ¶
func (c *Cert) GetRegistration() *registration.Resource
GetRegistration returns the server registration
func (*Cert) SetCertPath ¶
func (*Cert) SetChallengePath ¶
func (*Cert) SetKeyType ¶
Click to show internal directories.
Click to hide internal directories.