Upgrade server dependencies, manage them with govendor
This commit is contained in:
parent
ebee2746d6
commit
971278e7e5
1748 changed files with 196165 additions and 194500 deletions
|
@ -24,8 +24,8 @@ func Run(dir, domain, email, port string) (*state, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
client, err := acme.NewClient(URL, &user, KeySize)
|
||||
client.ExcludeChallenges([]string{"tls-sni-01"})
|
||||
client, err := acme.NewClient(URL, &user, acme.RSA2048)
|
||||
client.ExcludeChallenges([]acme.Challenge{acme.TLSSNI01})
|
||||
client.SetHTTPAddress(port)
|
||||
|
||||
if user.Registration == nil {
|
||||
|
@ -123,7 +123,7 @@ func (s *state) setOCSP(ocsp []byte) {
|
|||
}
|
||||
|
||||
func (s *state) obtain() error {
|
||||
cert, errors := s.client.ObtainCertificate([]string{s.domain}, true, nil)
|
||||
cert, errors := s.client.ObtainCertificate([]string{s.domain}, true, nil, false)
|
||||
if err := errors[s.domain]; err != nil {
|
||||
if _, ok := err.(acme.TOSError); ok {
|
||||
err := s.client.AgreeToTOS()
|
||||
|
@ -180,7 +180,7 @@ func (s *state) renew() bool {
|
|||
meta.PrivateKey = key
|
||||
|
||||
Renew:
|
||||
newMeta, err := s.client.RenewCertificate(meta, true)
|
||||
newMeta, err := s.client.RenewCertificate(meta, true, false)
|
||||
if err != nil {
|
||||
if _, ok := err.(acme.TOSError); ok {
|
||||
err := s.client.AgreeToTOS()
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package letsencrypt
|
||||
|
||||
import (
|
||||
"crypto"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/x509"
|
||||
|
@ -17,7 +18,7 @@ const defaultUser = "default"
|
|||
type User struct {
|
||||
Email string
|
||||
Registration *acme.RegistrationResource
|
||||
key *rsa.PrivateKey
|
||||
key crypto.PrivateKey
|
||||
}
|
||||
|
||||
func (u User) GetEmail() string {
|
||||
|
@ -28,7 +29,7 @@ func (u User) GetRegistration() *acme.RegistrationResource {
|
|||
return u.Registration
|
||||
}
|
||||
|
||||
func (u User) GetPrivateKey() *rsa.PrivateKey {
|
||||
func (u User) GetPrivateKey() crypto.PrivateKey {
|
||||
return u.key
|
||||
}
|
||||
|
||||
|
@ -86,7 +87,7 @@ func saveUser(user User) error {
|
|||
return ioutil.WriteFile(directory.UserRegistration(user.Email), jsonBytes, 0600)
|
||||
}
|
||||
|
||||
func loadRSAPrivateKey(file string) (*rsa.PrivateKey, error) {
|
||||
func loadRSAPrivateKey(file string) (crypto.PrivateKey, error) {
|
||||
keyBytes, err := ioutil.ReadFile(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -95,8 +96,10 @@ func loadRSAPrivateKey(file string) (*rsa.PrivateKey, error) {
|
|||
return x509.ParsePKCS1PrivateKey(keyBlock.Bytes)
|
||||
}
|
||||
|
||||
func saveRSAPrivateKey(key *rsa.PrivateKey, file string) error {
|
||||
pemKey := pem.Block{Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key)}
|
||||
func saveRSAPrivateKey(key crypto.PrivateKey, file string) error {
|
||||
pemKey := pem.Block{
|
||||
Type: "RSA PRIVATE KEY", Bytes: x509.MarshalPKCS1PrivateKey(key.(*rsa.PrivateKey)),
|
||||
}
|
||||
keyOut, err := os.Create(file)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/xenolf/lego/acme"
|
||||
)
|
||||
|
||||
func tempdir() string {
|
||||
|
@ -14,18 +13,10 @@ func tempdir() string {
|
|||
}
|
||||
|
||||
func testUser(t *testing.T, email string) {
|
||||
reg := &acme.RegistrationResource{
|
||||
URI: "test.com",
|
||||
Body: acme.Registration{
|
||||
Agreement: "agree?",
|
||||
},
|
||||
}
|
||||
|
||||
user, err := newUser(email)
|
||||
assert.Nil(t, err)
|
||||
key := user.GetPrivateKey()
|
||||
assert.NotNil(t, key)
|
||||
user.Registration = reg
|
||||
|
||||
err = saveUser(user)
|
||||
assert.Nil(t, err)
|
||||
|
@ -34,7 +25,6 @@ func testUser(t *testing.T, email string) {
|
|||
assert.Nil(t, err)
|
||||
assert.Equal(t, email, user.GetEmail())
|
||||
assert.Equal(t, key, user.GetPrivateKey())
|
||||
assert.Equal(t, reg, user.GetRegistration())
|
||||
}
|
||||
|
||||
func TestUser(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue