func Obtain(ob *ObtainRequest) (*certificate.Resource, error) {
	u, err := newUser(ob.Email)
	if err != nil {
		return nil, fmt.Errorf("Failed to NewUser, error: %s", err)
	}
	directory := ob.Directory
	if directory == "" {
		directory = directoryURL
	}
	// A client facilitates communication with the CA server.
	client, err := lego.NewClient(&lego.Config{
		HTTPClient: http.DefaultClient,
		CADirURL:   directory,
		User:       u,
		Certificate: lego.CertificateConfig{
			KeyType: certcrypto.RSA2048,
		},
	})
	if err != nil {
		return nil, fmt.Errorf("Failed to NewClient, error: %s", err)
	}

	// New users will need to register
	if _, err := client.Registration.Register(registration.RegisterOptions{
		// The client has a URL to the current Let's Encrypt Subscriber
		// Agreement. The user will need to agree to it.
		TermsOfServiceAgreed: true,
	}); err != nil {
		return nil, fmt.Errorf("Failed to Register, error: %s", err)
	}

	provider, err := newS3UploadingProvider(ob.Bucket)
	if err != nil {
		return nil, fmt.Errorf("Failed to NewS3UploadingPrivider: %w", err)
	}
	// We only use HTTP01
	if err := client.Challenge.SetHTTP01Provider(provider); err != nil {
		return nil, fmt.Errorf("Failed to SetChallengeProvider failed, error: %s", err)
	}

	return client.Certificate.Obtain(certificate.ObtainRequest{
		Domains: ob.Domains,
		// The acme library takes care of completing the challenges to obtain the certificate(s).
		// The domains must resolve to this machine or you have to use the DNS challenge.
		Bundle: ob.Bundle,
		// ELB doesn't support OCSP stapling
		MustStaple:     ob.MustStaple,
		PreferredChain: ob.PreferredChain,
	})
}
// Obtain server key and certificates
Obtain server key and certificates
// Obtain server key and certificates
func Obtain(ob *ObtainRequest) (*certificate.Resource, error) {
	u, err := newUser(ob.Email)
	if err != nil {
		return nil, fmt.Errorf("Failed to NewUser, error: %s", err)
	}
	directory := ob.Directory
	if directory == "" {
		directory = directoryURL
	}
	client, err := lego.NewClient(&lego.Config{
		HTTPClient: http.DefaultClient,
		CADirURL:   directory,
		User:       u,
		Certificate: lego.CertificateConfig{
			KeyType: certcrypto.RSA2048,
		},
	})
	if err != nil {
		return nil, fmt.Errorf("Failed to NewClient, error: %s", err)
	}
	if _, err := client.Registration.Register(registration.RegisterOptions{
		TermsOfServiceAgreed: true,
	}); err != nil {
		return nil, fmt.Errorf("Failed to Register, error: %s", err)
	}
	provider, err := newS3UploadingProvider(ob.Bucket)
	if err != nil {
		return nil, fmt.Errorf("Failed to NewS3UploadingPrivider: %w", err)
	}
	if err := client.Challenge.SetHTTP01Provider(provider); err != nil {
		return nil, fmt.Errorf("Failed to SetChallengeProvider failed, error: %s", err)
	}
	return client.Certificate.Obtain(certificate.ObtainRequest{
		Domains: ob.Domains,
		Bundle: ob.Bundle,
		MustStaple:     ob.MustStaple,
		PreferredChain: ob.PreferredChain,
	})
}
func Obtain ( ob * ObtainRequest ) ( * certificate . Resource , error ) { u , err := newUser ( ob . Email ) if err != nil { return nil , fmt . Errorf ( " " , err ) } directory := ob . Directory if directory == " " { directory = directoryURL } client , err := lego . NewClient ( & lego . Config { HTTPClient : http . DefaultClient , CADirURL : directory , User : u , Certificate : lego . CertificateConfig { KeyType : certcrypto . RSA2048 , } , } ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if _ , err := client . Registration . Register ( registration . RegisterOptions { TermsOfServiceAgreed : true , } ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } provider , err := newS3UploadingProvider ( ob . Bucket ) if err != nil { return nil , fmt . Errorf ( " " , err ) } if err := client . Challenge . SetHTTP01Provider ( provider ) ; err != nil { return nil , fmt . Errorf ( " " , err ) } return client . Certificate . Obtain ( certificate . ObtainRequest { Domains : ob . Domains , Bundle : ob . Bundle , MustStaple : ob . MustStaple , PreferredChain : ob . PreferredChain , } ) }
Obtain server key and certificates
Obtain server key and certificates
// A client facilitates communication with the CA server. // New users will need to register // The client has a URL to the current Let's Encrypt Subscriber // Agreement. The user will need to agree to it. // We only use HTTP01 // The acme library takes care of completing the challenges to obtain the certificate(s). // The domains must resolve to this machine or you have to use the DNS challenge. // ELB doesn't support OCSP stapling