Skip to content

Commit

Permalink
Initial docker-compose config for rufus/vetinari integration
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanMcCauley committed Apr 28, 2015
1 parent f86a6c5 commit c043e6d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM golang

COPY . /go/src/github.com/docker/vetinari

RUN go get github.com/docker/vetinari/cmd/vetinari-server
RUN GOPATH=/go/:/go/src/github.com/docker/vetinari/Godeps/_workspace go install github.com/docker/vetinari/cmd/vetinari-server

EXPOSE 4443

Expand Down
7 changes: 4 additions & 3 deletions cmd/vetinari-server/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"addr": ":4443",
"tls_cert_file": "../../fixtures/vetinari.pem",
"tls_key_file": "../../fixtures/vetinari.key"
}
},
"trust_service":{
"type": "local"
"hostname": ""
"type": "local",
"hostname": "",
"port": ""
}
}
12 changes: 12 additions & 0 deletions cmd/vetinari-server/dev-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"server": {
"addr": ":4443",
"tls_cert_file": "../../fixtures/ca.pem",
"tls_key_file": "../../fixtures/ca-key.pem"
},
"trust_service": {
"type": "remote",
"hostname": "rufus",
"port": "7899"
}
}
11 changes: 11 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
vetinari:
build: .
links:
- rufus
ports:
- "8080:8080"
rufus:
build: ../rufus
ports:
- "7899:7899"

10 changes: 8 additions & 2 deletions server/rufus_trust.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package server
import (
"errors"
"log"
"net"

"github.com/endophage/go-tuf/data"
"github.com/endophage/go-tuf/keys"

"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"

pb "github.com/docker/rufus/proto"
)
Expand All @@ -19,8 +21,12 @@ type RufusSigner struct {
sClient pb.SignerClient
}

func newRufusSigner(hostNameAndPort string) *RufusSigner {
conn, err := grpc.Dial(hostNameAndPort)
func newRufusSigner(hostname string, port string) *RufusSigner {
var opts []grpc.DialOption
netAddr := net.JoinHostPort(hostname, port)
creds := credentials.NewClientTLSFromCert(nil, hostname)
opts = append(opts, grpc.WithTransportCredentials(creds))
conn, err := grpc.Dial(netAddr, opts...)
if err != nil {
log.Fatalf("fail to dial: %v", err)
}
Expand Down
16 changes: 9 additions & 7 deletions server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ import (
// use directly for the TLS server, and generate children off for requests
func Run(ctx context.Context, conf *config.Configuration) error {

var trust signed.TrustService
if conf.TrustService.Type == "remote" {
log.Println("[Vetinari Server] : Using remote signing service")
trust = newRufusSigner(conf.TrustService.Hostname, conf.TrustService.Port)
} else {
log.Println("[Vetinari Server] : Using local signing service")
trust = signed.NewEd25519()
}

keypair, err := tls.LoadX509KeyPair(conf.Server.TLSCertFile, conf.Server.TLSKeyFile)
if err != nil {
return err
Expand Down Expand Up @@ -64,13 +73,6 @@ func Run(ctx context.Context, conf *config.Configuration) error {
tlsLsnr.Close()
}()

var trust signed.TrustService
if conf.TrustService.Type == "remote" {
netAddr := net.JoinHostPort(conf.TrustService.Hostname, conf.TrustService.Port)
trust = newRufusSigner(netAddr)
} else {
trust = signed.NewEd25519()
}

hand := utils.RootHandlerFactory(&utils.InsecureAuthorizer{}, utils.NewContext, trust)

Expand Down

0 comments on commit c043e6d

Please sign in to comment.