bugfixing so it builds with new gotuf repo. Need to work out what I'm going with CanSign method, might get rid of it and just inspect error response

This commit is contained in:
David Lawrence 2015-06-12 15:00:36 -07:00
parent cc0782d3d2
commit 13c4d05b79
2 changed files with 13 additions and 10 deletions

View File

@ -50,8 +50,8 @@ func main() {
logrus.Fatal("Error parsing config: ", err.Error()) logrus.Fatal("Error parsing config: ", err.Error())
return // not strictly needed but let's be explicit return // not strictly needed but let's be explicit
} }
if conf.Logging { if conf.Logging.Level > 0 {
logrus.SetLevel(conf.Logging.Level) logrus.SetLevel(logrus.Level(conf.Logging.Level))
} }
sigHup := make(chan os.Signal) sigHup := make(chan os.Signal)
@ -60,7 +60,7 @@ func main() {
signal.Notify(sigHup, syscall.SIGHUP) signal.Notify(sigHup, syscall.SIGHUP)
signal.Notify(sigTerm, syscall.SIGTERM) signal.Notify(sigTerm, syscall.SIGTERM)
var trust signed.TrustService var trust signed.CryptoService
if conf.TrustService.Type == "remote" { if conf.TrustService.Type == "remote" {
logrus.Info("[Vetinari] : Using remote signing service") logrus.Info("[Vetinari] : Using remote signing service")
trust = signer.NewRufusSigner(conf.TrustService.Hostname, conf.TrustService.Port, conf.TrustService.TLSCAFile) trust = signer.NewRufusSigner(conf.TrustService.Hostname, conf.TrustService.Port, conf.TrustService.TLSCAFile)

View File

@ -7,7 +7,6 @@ import (
"github.com/Sirupsen/logrus" "github.com/Sirupsen/logrus"
pb "github.com/docker/rufus/proto" pb "github.com/docker/rufus/proto"
"github.com/endophage/gotuf/data" "github.com/endophage/gotuf/data"
"github.com/endophage/gotuf/keys"
"golang.org/x/net/context" "golang.org/x/net/context"
"google.golang.org/grpc" "google.golang.org/grpc"
"google.golang.org/grpc/credentials" "google.golang.org/grpc/credentials"
@ -41,7 +40,7 @@ func NewRufusSigner(hostname string, port string, tlscafile string) *RufusSigner
} }
// addKey allows you to add a private key to the trust service // addKey allows you to add a private key to the trust service
func (trust *RufusSigner) addKey(k *keys.PrivateKey) error { func (trust *RufusSigner) addKey(k *data.PrivateKey) error {
return errors.New("Not implemented: RufusSigner.addKey") return errors.New("Not implemented: RufusSigner.addKey")
} }
@ -75,19 +74,19 @@ func (trust *RufusSigner) Sign(keyIDs []string, toSign []byte) ([]data.Signature
} }
// Create creates a remote key and returns the PublicKey associated with the remote private key // Create creates a remote key and returns the PublicKey associated with the remote private key
func (trust *RufusSigner) Create() (*keys.PublicKey, error) { func (trust *RufusSigner) Create() (*data.PublicKey, error) {
publicKey, err := trust.kmClient.CreateKey(context.Background(), &pb.Void{}) publicKey, err := trust.kmClient.CreateKey(context.Background(), &pb.Void{})
if err != nil { if err != nil {
return nil, err return nil, err
} }
//TODO(mccauley): Update API to return algorithm and/or take it as a param //TODO(mccauley): Update API to return algorithm and/or take it as a param
public := keys.NewPublicKey("TODOALGORITHM", publicKey.PublicKey) public := data.NewPublicKey("TODOALGORITHM", string(publicKey.PublicKey))
return public, nil return public, nil
} }
// PublicKeys returns the public key(s) associated with the passed in keyIDs // PublicKeys returns the public key(s) associated with the passed in keyIDs
func (trust *RufusSigner) PublicKeys(keyIDs ...string) (map[string]*keys.PublicKey, error) { func (trust *RufusSigner) PublicKeys(keyIDs ...string) (map[string]*data.PublicKey, error) {
publicKeys := make(map[string]*keys.PublicKey) publicKeys := make(map[string]*data.PublicKey)
for _, ID := range keyIDs { for _, ID := range keyIDs {
keyID := pb.KeyID{ID: ID} keyID := pb.KeyID{ID: ID}
sig, err := trust.kmClient.GetKeyInfo(context.Background(), &keyID) sig, err := trust.kmClient.GetKeyInfo(context.Background(), &keyID)
@ -95,7 +94,11 @@ func (trust *RufusSigner) PublicKeys(keyIDs ...string) (map[string]*keys.PublicK
return nil, err return nil, err
} }
publicKeys[sig.KeyID.ID] = publicKeys[sig.KeyID.ID] =
keys.NewPublicKey("TODOALGORITHM", sig.PublicKey) data.NewPublicKey("TODOALGORITHM", string(sig.PublicKey))
} }
return publicKeys, nil return publicKeys, nil
} }
func (trust *RufusSigner) CanSign(kID string) bool {
return true
}