0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2025-01-13 22:51:08 -05:00

#640 cleaning Code Style [Part 1]

This commit is contained in:
elcore 2016-02-28 18:40:51 +01:00 committed by Eldin Hadzic
parent 43c339c7e3
commit 804f495255
4 changed files with 14 additions and 25 deletions

View file

@ -34,16 +34,7 @@ var NewACMEClient = func(email string, allowPrompts bool) (*ACMEClient, error) {
}
// The client facilitates our communication with the CA server.
var kt acme.KeyType
if rsaKeySizeToUse == Rsa2048 {
kt = acme.RSA2048
} else if rsaKeySizeToUse == Rsa4096 {
kt = acme.RSA4096
} else {
// TODO(hkjn): Support more types? Current changes are quick fix for #640.
return nil, fmt.Errorf("https: unsupported keysize")
}
client, err := acme.NewClient(CAUrl, &leUser, kt)
client, err := acme.NewClient(CAUrl, &leUser, KeyTypeToUse)
if err != nil {
return nil, err
}

View file

@ -11,16 +11,14 @@ import (
)
func init() {
rsaKeySizeToUse = 2048 // TODO(hkjn): Bring back support for small
// keys to speed up tests? Current changes
// are quick fix for #640.
KeySize = 2048
}
func TestSaveAndLoadRSAPrivateKey(t *testing.T) {
keyFile := "test.key"
defer os.Remove(keyFile)
privateKey, err := rsa.GenerateKey(rand.Reader, rsaKeySizeToUse)
privateKey, err := rsa.GenerateKey(rand.Reader, KeySize)
if err != nil {
t.Fatal(err)
}

View file

@ -401,21 +401,21 @@ var (
// default port for the challenge must be forwarded to this one.
const AlternatePort = "5033"
// KeySize represents the length of a key in bits.
type KeySize int
// Key sizes are used to determine the strength of a key.
// Possible types for a key.
const (
Ecc224 KeySize = 224
Ecc256 = 256
Rsa2048 = 2048
Rsa4096 = 4096
RSA2048 = acme.RSA2048
RSA4096 = acme.RSA4096
EC256 = acme.EC256
EC384 = acme.EC384
)
// rsaKeySizeToUse is the size to use for new RSA keys.
// KeyTypeToUse is the type to use for new keys.
// This shouldn't need to change except for in tests;
// the size can be drastically reduced for speed.
var rsaKeySizeToUse = Rsa2048
var KeyTypeToUse = RSA2048
// KeySize should be equal to KeyTypeToUse: KeyTypeToUse = 4096 -> KeySize = 4096
var KeySize = 2048
// stopChan is used to signal the maintenance goroutine
// to terminate.

View file

@ -104,7 +104,7 @@ func saveUser(user User) error {
// instead. It does NOT prompt the user.
func newUser(email string) (User, error) {
user := User{Email: email}
privateKey, err := rsa.GenerateKey(rand.Reader, rsaKeySizeToUse)
privateKey, err := rsa.GenerateKey(rand.Reader, KeySize)
if err != nil {
return user, errors.New("error generating private key: " + err.Error())
}