mirror of
				https://github.com/caddyserver/caddy.git
				synced 2025-11-03 19:17:29 -05:00 
			
		
		
		
	
		
			
				
	
	
		
			36 lines
		
	
	
		
			756 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			36 lines
		
	
	
		
			756 B
		
	
	
	
		
			Go
		
	
	
	
	
	
package config
 | 
						|
 | 
						|
import (
 | 
						|
	"crypto/rand"
 | 
						|
	"crypto/rsa"
 | 
						|
	"errors"
 | 
						|
 | 
						|
	"github.com/xenolf/lego/acme"
 | 
						|
)
 | 
						|
 | 
						|
func NewLetsEncryptUser(email string) (LetsEncryptUser, error) {
 | 
						|
	user := LetsEncryptUser{Email: email}
 | 
						|
	privateKey, err := rsa.GenerateKey(rand.Reader, 2048)
 | 
						|
	if err != nil {
 | 
						|
		return user, errors.New("error generating private key: " + err.Error())
 | 
						|
	}
 | 
						|
	user.Key = privateKey
 | 
						|
	return user, nil
 | 
						|
}
 | 
						|
 | 
						|
type LetsEncryptUser struct {
 | 
						|
	Email        string
 | 
						|
	Registration *acme.RegistrationResource
 | 
						|
	Key          *rsa.PrivateKey
 | 
						|
}
 | 
						|
 | 
						|
func (u LetsEncryptUser) GetEmail() string {
 | 
						|
	return u.Email
 | 
						|
}
 | 
						|
func (u LetsEncryptUser) GetRegistration() *acme.RegistrationResource {
 | 
						|
	return u.Registration
 | 
						|
}
 | 
						|
func (u LetsEncryptUser) GetPrivateKey() *rsa.PrivateKey {
 | 
						|
	return u.Key
 | 
						|
}
 |