autocert

package
v1.1.13 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package autocert

自动生成更新ssl证书 基于acme 简单的http认证方式,可以启动在:http以供challenge时使用

使用 cert := autocert.NewDefault()

cert.RunAndStop() 证书将会保存至fushin-cert目录下

Index

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 AutoCert

func AutoCert(c *Cert, err error)

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 HttpRun

func HttpRun() error

func HttpRunForOnce

func HttpRunForOnce() error

func HttpRunWithCtx

func HttpRunWithCtx(ctx context.Context)

func NewClient

func NewClient(account *Cert) (*lego.Client, error)

NewClient returns a new Lets Encrypt client

func ObtainDomains

func ObtainDomains(c *lego.Client, domains []string) (*certificate.Resource, error)

ObtainDomains 3.注册域名

func RegAccount

func RegAccount(c *lego.Client) (*registration.Resource, error)

RegAccount 2.注册账户

func RegProvider

func RegProvider(c *lego.Client, challenge string) error

RegProvider 1.注册质询

func SaveCert

func SaveCert(p string, cert *certificate.Resource) error

SaveCert 保存cert文件 默认会保存到$CertRoot下

func SetCertCacheDir

func SetCertCacheDir(p string)

SetCertCacheDir 设置全局的证书缓存目录

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 NewCert

func NewCert(certPath, email string, domains []string) Cert

NewCert 根据缓存目录创建证书生成器

func NewDefault

func NewDefault(email string, domains []string) Cert

func (*Cert) AddDomains

func (c *Cert) AddDomains(ds []string)

func (*Cert) AddRegistration

func (c *Cert) AddRegistration(reg *registration.Resource)

func (*Cert) Create

func (c *Cert) Create() (*certificate.Resource, error)

Create 返回生成的证书列表

func (*Cert) GetCertPath

func (c *Cert) GetCertPath() string

func (*Cert) GetDomains

func (c *Cert) GetDomains() []string

func (*Cert) GetEmail

func (c *Cert) GetEmail() string

GetEmail returns the email address for the account

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) Ready

func (c *Cert) Ready() error

Ready 是否准备就绪

func (*Cert) Run

func (c *Cert) Run() (err error)

Run 作为自动更新的服务端启动

func (*Cert) RunAndStop

func (c *Cert) RunAndStop() error

RunAndStop 仅用于下载申请证书 在占用完毕80端口后会释放

func (*Cert) SetCertPath

func (c *Cert) SetCertPath(p string)

func (*Cert) SetChallengePath

func (c *Cert) SetChallengePath(p string)

func (*Cert) SetKeyType

func (c *Cert) SetKeyType(t string)

func (*Cert) SetRenew

func (c *Cert) SetRenew(t int)

Jump to

Keyboard shortcuts

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