certLib

package
v0.0.0-...-93bf83b Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanCsrFil

func CleanCsrFil(csrFilnam string, csrList *CsrList) (err error)

func CreateCsr

func CreateCsr(csrTpl x509.CertificateRequest, certKey *ecdsa.PrivateKey) (csr []byte, err error)

func CreateCsrTpl

func CreateCsrTpl(csrData CsrDat) (template x509.CertificateRequest)

create certficate sign request

func CreateCsrTplNew

func CreateCsrTplNew(csrList *CsrList, domIdx int) (template x509.CertificateRequest, err error)

create certficate sign request

func DecodeKey

func DecodeKey(pemEncoded string, pemEncodedPub string) (*ecdsa.PrivateKey, *ecdsa.PublicKey)

func EncodeKey

func EncodeKey(privateKey *ecdsa.PrivateKey, publicKey *ecdsa.PublicKey) (string, string)

func GenCertKey

func GenCertKey() (certKey *ecdsa.PrivateKey, err error)

func GenerateCertName

func GenerateCertName(domain string) (certName string, err error)

generate cert names

func GetAcmeClient

func GetAcmeClient(acntNam string) (cl *acme.Client, err error)

function to retrieve keys for LetsEncrypt acme account

func GetCertDir

func GetCertDir(acntNam string) (certDir string, err error)

func GetLEClient

func GetLEClient(acntNam string, dbg bool) (cl *acme.Client, err error)

func InitCertLib

func InitCertLib() (certobj *certLibObj, err error)

func ParseCertsInfo

func ParseCertsInfo(derCerts [][]byte, certInfoFilnam string) (err error)

func ParseCsr

func ParseCsr(csr []byte) (certReq *x509.CertificateRequest, err error)

func PrintAccount

func PrintAccount(acnt *acme.Account)

func PrintAuth

func PrintAuth(auth *acme.Authorization)

func PrintCert

func PrintCert(cert *x509.Certificate)

func PrintCertInfo

func PrintCertInfo(cert x509.Certificate, i int)

func PrintCertObj

func PrintCertObj(cert *certLibObj)

func PrintChallenge

func PrintChallenge(chal *acme.Challenge, domain string)

func PrintClient

func PrintClient(client *acme.Client)

func PrintCsrList

func PrintCsrList(csrlist *CsrList)

xx

func PrintCsrReq

func PrintCsrReq(req *x509.CertificateRequest)

func PrintDir

func PrintDir(dir acme.Directory)

func PrintDomains

func PrintDomains(domains []string)

func PrintJsAccount

func PrintJsAccount(acnt *JsAcnt)

func PrintLEAcnt

func PrintLEAcnt(acnt *LEObj)

func PrintOrder

func PrintOrder(ord acme.Order)

func PrintPkixNam

func PrintPkixNam(subj pkix.Name)

func ReadPemCerts

func ReadPemCerts(certFile string, dbg bool) (err error)

func RegisterClient

func RegisterClient(ctx context.Context, client *acme.Client, contacts []string, dbg bool) (ac *acme.Account, err error)

registers client with the acme server

func SaveAcmeClient

func SaveAcmeClient(client *acme.Client, filNam string) (err error)

function that saves the keys in certDir

func SaveCertsPem

func SaveCertsPem(derCerts [][]byte, certFile string) (err error)

func WriteCsrFil

func WriteCsrFil(outFilnam string, csrDatList *CsrList) (err error)

Types

type CertList

type CertList struct {
	CertNam string    `yaml:"certName"`
	Domains []string  `yaml:"domains"`
	LEUrl   string    `yaml:"LEUrl"`
	Valid   time.Time `yaml:"valid"`
	Expire  time.Time `yaml:"expire"`
}

type CsrDat

type CsrDat struct {
	Domain    string    `yaml:"domain"`
	Email     string    `yaml:"email"`
	PemFil    string    `yaml:"pemfil"`
	ChalRecId string    `yaml:"chalrec"`
	Token     string    `yaml:"token"`
	TokVal    string    `yaml:"tokval"`
	TokUrl    string    `yaml:"tokUrl"`
	TokIssue  time.Time `yaml:"issue"`
	TokExp    time.Time `yaml:"expire"`
	OrderUrl  string    `yaml:"orderUrl"`
	CertUrl   string    `yaml:"certUrl"`
	Name      pkixName  `yaml:"Name"`
}

type CsrList

type CsrList struct {
	AcntName string    `yaml:"account"`
	LastLU   time.Time `yaml:"last"`
	OrderUrl string    `yaml:"orderUrl"`
	CertUrl  string    `yaml:"certUrl"`
	Domains  []CsrDat  `yaml:"domains"`
}

func ReadCsrFil

func ReadCsrFil(inFilnam string) (csrDatList *CsrList, err error)

functions that reads CSRList from a file

type JsAcnt

type JsAcnt struct {
	// URI is the account unique ID, which is also a URL used to retrieve
	// account data from the CA.
	// When interfacing with RFC 8555-compliant CAs, URI is the "kid" field
	// value in JWS signed requests.
	URI string `yaml: "URI"`

	// Contact is a slice of contact info used during registration.
	// See https://tools.ietf.org/html/rfc8555#section-7.3 for supported
	// formats.
	Contact []string `yaml: "Contact"`

	// Status indicates current account status as returned by the CA.
	// Possible values are StatusValid, StatusDeactivated, and StatusRevoked.
	Status string `yaml: "Status"`

	// OrdersURL is a URL from which a list of orders submitted by this account
	// can be fetched.
	OrdersURL string `yaml: "OrdersURL"`

	// The terms user has agreed to.
	// A value not matching CurrentTerms indicates that the user hasn't agreed
	// to the actual Terms of Service of the CA.
	//
	// It is non-RFC 8555 compliant. Package users can store the ToS they agree to
	// during Client's Register call in the prompt callback function.
	AgreedTerms string `yaml: "Terms"`

	// Actual terms of a CA.
	//
	// It is non-RFC 8555 compliant. Use Directory's Terms field.
	// When a CA updates their terms and requires an account agreement,
	// a URL at which instructions to do so is available in Error's Instance field.
	CurrentTerms string `yaml: "CurTerms"`

	// Authz is the authorization URL used to initiate a new authz flow.
	//
	// It is non-RFC 8555 compliant. Use Directory's AuthzURL or OrderURL.
	Authz string `yaml: "Authz"`

	// Authorizations is a URI from which a list of authorizations
	// granted to this account can be fetched via a GET request.
	//
	// It is non-RFC 8555 compliant and is obsoleted by OrdersURL.
	Authorizations string `yaml: "Auth"`
	// Certificates is a URI from which a list of certificates
	// issued for this account can be fetched via a GET request.
	//
	// It is non-RFC 8555 compliant and is obsoleted by OrdersURL.
	Certificates string `yaml: "Certs"`

	// ExternalAccountBinding represents an arbitrary binding to an account of
	// the CA which the ACME server is tied to.
	// See https://tools.ietf.org/html/rfc8555#section-7.3.4 for more details.
	ExternalAccountBinding *acme.ExternalAccountBinding `yaml: "ExtAcct"`
}

yaml version of type acme.Account

type LEObj

type LEObj struct {
	AcntNam       string    `yaml:"AcntName"`
	AcntId        string    `yaml:"AcntId"`
	PrivKeyFilnam string    `yaml:"PrivKeyFilnam"`
	PubKeyFilnam  string    `yaml:"PubKeyFilnam"`
	Updated       time.Time `yaml:"update"`
	//	Client *acme.Client
	//	Acnt *acme.Account
	Contacts []string `yaml:"contacts"`
	Remove   bool     `yaml:"remove"`
	UseProd  bool     `yaml:"useProd"`
	TestUrl  string   `yaml:"TestUrl"`
	ProdUrl  string   `yaml:"ProdUrl"`
}

func CreateLEAccount

func CreateLEAccount(acntNam string, dbg bool) (le *LEObj, err error)

function that creates a new client

Jump to

Keyboard shortcuts

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