From 49c2807ba14bbac97376f3c5f4ece85b51386a55 Mon Sep 17 00:00:00 2001 From: Henrik Jonsson Date: Sat, 27 Feb 2016 17:49:19 +0100 Subject: [PATCH] Fix build after https://github.com/xenolf/lego/commit/0e26b Fix up last-second changes Fixes #640 --- caddy/https/client.go | 11 ++++++++++- caddy/https/crypto_test.go | 4 +++- caddy/https/user.go | 3 ++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/caddy/https/client.go b/caddy/https/client.go index b47fd57f3..40e7a7098 100644 --- a/caddy/https/client.go +++ b/caddy/https/client.go @@ -34,7 +34,16 @@ var NewACMEClient = func(email string, allowPrompts bool) (*ACMEClient, error) { } // The client facilitates our communication with the CA server. - client, err := acme.NewClient(CAUrl, &leUser, rsaKeySizeToUse) + 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) if err != nil { return nil, err } diff --git a/caddy/https/crypto_test.go b/caddy/https/crypto_test.go index 875f2d217..39cd27b53 100644 --- a/caddy/https/crypto_test.go +++ b/caddy/https/crypto_test.go @@ -11,7 +11,9 @@ import ( ) func init() { - rsaKeySizeToUse = 128 // make tests faster; small key size OK for testing + rsaKeySizeToUse = 2048 // TODO(hkjn): Bring back support for small + // keys to speed up tests? Current changes + // are quick fix for #640. } func TestSaveAndLoadRSAPrivateKey(t *testing.T) { diff --git a/caddy/https/user.go b/caddy/https/user.go index c5a742526..203e07a27 100644 --- a/caddy/https/user.go +++ b/caddy/https/user.go @@ -2,6 +2,7 @@ package https import ( "bufio" + "crypto" "crypto/rand" "crypto/rsa" "encoding/json" @@ -34,7 +35,7 @@ func (u User) GetRegistration() *acme.RegistrationResource { } // GetPrivateKey gets u's private key. -func (u User) GetPrivateKey() *rsa.PrivateKey { +func (u User) GetPrivateKey() crypto.PrivateKey { return u.key }