package acme import ( "crypto/ecdsa" "crypto/elliptic" "crypto/rand" "github.com/go-acme/lego/v4/certcrypto" "github.com/go-acme/lego/v4/lego" "github.com/go-acme/lego/v4/registration" ) type DnsHelper interface { Apply() } func Register(email string) *RegisterRes { privateKey, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { panic(err) } user := User{ Email: email, Key: privateKey, } config := lego.NewConfig(&user) config.CADirURL = lego.LEDirectoryProduction config.Certificate.KeyType = certcrypto.RSA2048 client, err := lego.NewClient(config) if err != nil { panic(err) } resource, err := client.Registration.Register(registration.RegisterOptions{TermsOfServiceAgreed: true}) if err != nil { panic(err) } user.Registration = resource return user.ToRegister() }