elego

package module
v0.1.1 Latest Latest
Warning

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

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

README

elego

Use the simplest Lego to generate SSL

Install(go1.22.12 )

go install github.com/pkg6/elego/.cli/elego@latest

Install pkg (go1.22.12 )

go get github.com/pkg6/elego

Install(compressed file)

cd /usr/local/elego
wget https://github.com/pkg6/elego/releases/download/v0.1.0/elego_linux_amd64.tar.gz
tar -xzvf elego_linux_amd64.tar.gz
rm -rf elego_linux_amd64.tar.gz
//Add environment variables according to requirements
export PATH=$PATH:/usr/local/elego
export CLOUDFLARE_EMAIL=you@example.com
export CLOUDFLARE_API_KEY=b9841238feb177a84330febba8a83208921177bffe733
elego --domain="test.example.com" --dns="cloudflare" --path="/etc/nginx/ssl/"

Help

# ./elego  --help
Usage of ./elego:
  -cache string
    	When creating, a cache file will be generated and the path needs to be saved (default "/Users/baigedi/.elego")
  -dns string
    	Enter your DNS name, please refer to https://go-acme.github.io/lego/dns/index.html
  -domain string
    	Need to generate SSL domain names
  -email string
    	email (default "elego@darwin.com")
  -force
    	Should a new certificate be forcibly generated
  -path string
    	Path for saving certificates (default "/etc/nginx/ssl/")
  -webroot string
    	Directory for domain deployment

use webroot

elego --domain="test.example.com" --webroot="/data/wwwroot/test.example.com" --path="/etc/nginx/ssl/"

use dns

https://go-acme.github.io/lego/dns/index.html

export CLOUDFLARE_EMAIL=you@example.com
export CLOUDFLARE_API_KEY=b9841238feb177a84330febba8a83208921177bffe733
elego --domain="test.example.com" --dns="cloudflare" --path="/etc/nginx/ssl/"

Documentation

Index

Constants

This section is empty.

Variables

Functions

func CheckCertExpiry

func CheckCertExpiry(certPath string) (valid bool, expireDay float64)

func CopyFile

func CopyFile(content []byte, path string) error

func CreateNonExistingFolder

func CreateNonExistingFolder(path string) error

func ObtainCertificate

func ObtainCertificate(client *lego.Client, domains []string) (*certificate.Resource, error)

func SetChallenge

func SetChallenge(client *lego.Client, challenge IChallenge) error

Types

type Account

type Account struct {
	Email        string                 `json:"email"`
	Registration *registration.Resource `json:"registration"`
	Key          crypto.PrivateKey      `json:"-"`
}

Account represents a users local saved credentials.

func NewLegoClient

func NewLegoClient(accountStorage *AccountsStorage, register IRegister) (account *Account, client *lego.Client, err error)

func (*Account) GetEmail

func (a *Account) GetEmail() string

GetEmail returns the email address for the account.

func (*Account) GetPrivateKey

func (a *Account) GetPrivateKey() crypto.PrivateKey

GetPrivateKey returns the private RSA account key.

func (*Account) GetRegistration

func (a *Account) GetRegistration() *registration.Resource

GetRegistration returns the server registration.

type AccountsStorage

type AccountsStorage struct {
	Email    string
	CADirURL string
	// contains filtered or unexported fields
}

func NewAccountsStorage

func NewAccountsStorage(accountSavePath, email, CADirURL string) (*AccountsStorage, error)

NewAccountsStorage Creates a new AccountsStorage.

func (*AccountsStorage) GetEmail

func (s *AccountsStorage) GetEmail() string

func (*AccountsStorage) LoadAccount

func (s *AccountsStorage) LoadAccount() (*Account, error)

func (*AccountsStorage) Remove

func (s *AccountsStorage) Remove()

func (*AccountsStorage) Save

func (s *AccountsStorage) Save(account *Account) error

type DNSChallenge

type DNSChallenge struct {
	DNS                         string
	Servers                     []string
	PropagationWait             int
	Timeout                     int
	AuthoritativeNssPropagation bool
	RecursiveNssPropagation     bool
}

func (*DNSChallenge) Set

func (w *DNSChallenge) Set(client *lego.Client) error

type EABRegister

type EABRegister struct {
	TermsOfServiceAgreed bool
	Kid                  string
	HmacEncoded          string
}

func (*EABRegister) Register

func (r *EABRegister) Register(lego *lego.Client) (*registration.Resource, error)

type HTTPChallenge

type HTTPChallenge struct {
	HeaderName string
}

func (*HTTPChallenge) Set

func (w *HTTPChallenge) Set(client *lego.Client) error

type HTTPMemcachedHostChallenge

type HTTPMemcachedHostChallenge struct {
	Hosts []string
}

func (*HTTPMemcachedHostChallenge) Set

func (w *HTTPMemcachedHostChallenge) Set(client *lego.Client) error

type HTTPPortChallenge

type HTTPPortChallenge struct {
	HostPort   string
	HeaderName string
}

func (*HTTPPortChallenge) Set

func (w *HTTPPortChallenge) Set(client *lego.Client) error

type HTTPS3BucketChallenge

type HTTPS3BucketChallenge struct {
	Bucket string
}

func (*HTTPS3BucketChallenge) Set

func (w *HTTPS3BucketChallenge) Set(client *lego.Client) error

type HTTPWebrootChallenge

type HTTPWebrootChallenge struct {
	WebRoot string
}

func (*HTTPWebrootChallenge) Set

func (w *HTTPWebrootChallenge) Set(client *lego.Client) error

type IChallenge

type IChallenge interface {
	Set(client *lego.Client) error
}

type IRegister

type IRegister interface {
	Register(lego *lego.Client) (*registration.Resource, error)
}

type Register

type Register struct {
}

func (*Register) Register

func (r *Register) Register(lego *lego.Client) (*registration.Resource, error)

type TLSChallenge

type TLSChallenge struct {
}

func (*TLSChallenge) Set

func (w *TLSChallenge) Set(client *lego.Client) error

type TLSPortChallenge

type TLSPortChallenge struct {
	HostPort string
}

func (*TLSPortChallenge) Set

func (w *TLSPortChallenge) Set(client *lego.Client) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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