first iteration to automate certificate generation
This commit is contained in:
43
certs/certs.go
Normal file
43
certs/certs.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package certs
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
|
||||
"github.com/go-acme/lego/v4/certificate"
|
||||
"github.com/go-acme/lego/v4/challenge/dns01"
|
||||
"github.com/go-acme/lego/v4/lego"
|
||||
"local-ip.sh/xip"
|
||||
)
|
||||
|
||||
type certsClient struct {
|
||||
legoClient *lego.Client
|
||||
}
|
||||
|
||||
func (c *certsClient) RequestCertificate() {
|
||||
certificates, err := c.legoClient.Certificate.Obtain(certificate.ObtainRequest{
|
||||
Domains: []string{"*.local-ip.sh"},
|
||||
Bundle: true,
|
||||
})
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Printf("%#v\n", certificates)
|
||||
}
|
||||
|
||||
func NewCertsClient(xip *xip.Xip, user *Account) *certsClient {
|
||||
config := lego.NewConfig(user)
|
||||
config.CADirURL = caDirUrl
|
||||
legoClient, err := lego.NewClient(config)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
provider := newProviderLocalIp(xip)
|
||||
legoClient.Challenge.SetDNS01Provider(provider, dns01.AddRecursiveNameservers([]string{"1.1.1.1:53", "8.8.8.8:53"}))
|
||||
|
||||
return &certsClient{
|
||||
legoClient,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user