Skip to content
This repository has been archived by the owner on Sep 26, 2021. It is now read-only.

Commit

Permalink
Investigate 1954 certificate always regenerated
Browse files Browse the repository at this point in the history
Signed-off-by: David Gageot <david@gageot.net>
  • Loading branch information
dgageot committed Oct 21, 2015
1 parent c442690 commit c9217e8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
1 change: 1 addition & 0 deletions commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ func runActionForeachMachine(actionName string, machines []*host.Host) []error {
go machineCommand(actionName, machine, serialChan)
if err := <-serialChan; err != nil {
log.Errorln(err)
errs = append(errs, err)
}
close(serialChan)
}
Expand Down
2 changes: 1 addition & 1 deletion commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func checkCert(hostUrl string, authOptions *auth.AuthOptions, c *cli.Context) er
authOptions.ServerKeyPath,
)
if err != nil {
return fmt.Errorf("Error attempting to validate the certficate: %s", err)
return fmt.Errorf("Error attempting to validate the certs: %s", err)
}

if !valid {
Expand Down
6 changes: 6 additions & 0 deletions libmachine/cert/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"net"
"os"
"time"

"github.com/docker/machine/libmachine/log"
)

type ErrValidatingCert struct {
Expand Down Expand Up @@ -174,6 +176,7 @@ func GenerateCert(hosts []string, certFile, keyFile, caFile, caKeyFile, org stri
return nil
}

// ValidateCertificate validate the certificate installed on the vm.
func ValidateCertificate(addr, caCertPath, serverCertPath, serverKeyPath string) (bool, error) {
caCert, err := ioutil.ReadFile(caCertPath)
if err != nil {
Expand All @@ -195,12 +198,15 @@ func ValidateCertificate(addr, caCertPath, serverCertPath, serverKeyPath string)
return false, ErrValidatingCert{err}
}

log.Debugf("Configuration: +%v", tlsConfig)

dialer := &net.Dialer{
Timeout: time.Second * 2,
}

_, err = tls.DialWithDialer(dialer, "tcp", addr, tlsConfig)
if err != nil {
log.Debugf("Certs are not valid: %s", err)
return false, nil
}

Expand Down
6 changes: 1 addition & 5 deletions libmachine/provision/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,11 +179,7 @@ func ConfigureAuth(p Provisioner) error {
return err
}

if err := waitForDocker(p, dockerPort); err != nil {
return err
}

return nil
return waitForDocker(p, dockerPort)
}

func matchNetstatOut(reDaemonListening, netstatOut string) bool {
Expand Down

0 comments on commit c9217e8

Please sign in to comment.