From 347c11ec42264c579eb3f19494e4f75ab8bb8f0d Mon Sep 17 00:00:00 2001 From: Niall Sheridan Date: Thu, 9 Aug 2018 23:29:20 +0100 Subject: Remove gRPC This hasn't been enabled in a while due to gRPC limitations --- client/client.go | 56 -------------------------------------------------------- 1 file changed, 56 deletions(-) (limited to 'client') diff --git a/client/client.go b/client/client.go index 43420e5..58cc6bb 100644 --- a/client/client.go +++ b/client/client.go @@ -11,19 +11,12 @@ import ( "net/http" "net/url" "path" - "strings" "time" - "google.golang.org/grpc" - "google.golang.org/grpc/metadata" - - "github.com/golang/protobuf/ptypes" "github.com/nsheridan/cashier/lib" - "github.com/nsheridan/cashier/proto" "github.com/pkg/errors" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" - "golang.org/x/net/context" ) // SavePublicFiles installs the public part of the cert and key. @@ -147,52 +140,3 @@ func Sign(pub ssh.PublicKey, token string, message string, conf *Config) (*ssh.C } return cert, nil } - -// RPCSign sends the public key to the CA to be signed. -func RPCSign(pub ssh.PublicKey, token string, message string, conf *Config) (*ssh.Certificate, error) { - var opts []grpc.DialOption - var srv string - if strings.HasPrefix(conf.CA, "https://") { - srv = strings.TrimPrefix(conf.CA, "https://") - } else { - srv = strings.TrimPrefix(conf.CA, "http://") - opts = append(opts, grpc.WithInsecure()) - } - conn, err := grpc.Dial(srv, opts...) - if err != nil { - return nil, err - } - defer conn.Close() - stub := proto.NewSignerClient(conn) - lifetime, err := time.ParseDuration(conf.Validity) - if err != nil { - return nil, err - } - deadline := time.Now().Add(lifetime) - ts, err := ptypes.TimestampProto(deadline) - if err != nil { - return nil, err - } - req := &proto.SignRequest{ - Key: lib.GetPublicKey(pub), - ValidUntil: ts, - Message: message, - } - md := metadata.New(map[string]string{ - "security": "authorization", - "payload": token, - }) - r, err := stub.Sign(metadata.NewOutgoingContext(context.TODO(), md), req) - if err != nil { - return nil, err - } - k, _, _, _, err := ssh.ParseAuthorizedKey(r.Cert) - if err != nil { - return nil, err - } - cert, ok := k.(*ssh.Certificate) - if !ok { - return nil, errors.New("did not receive a valid certificate from server") - } - return cert, nil -} -- cgit v1.2.3