Skip to content

Commit

Permalink
[FAB-4141] Default CA lookup fails
Browse files Browse the repository at this point in the history
By default, the default CA in a server has no CA
name (empty string). However, the default CA can be
started up with a CA name specified, but if this done
then client request does not get routed to it appropriately.
If the client does not specify a CA name (empty string), the
server will not correctly direct traffic to the default CA.

Code was added to correctly set the default CA name in client
request when a client makes a request to the default CA.

See [FAB-4141] for more info

Change-Id: If12ab1b4861961a3106bb76f1bee64e2b94cedcd
Signed-off-by: Saad Karim <[email protected]>
  • Loading branch information
Saad Karim committed May 25, 2017
1 parent 406df3c commit ac8695b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions lib/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,33 @@ func TestMultiCAConfigs(t *testing.T) {

}

func TestDefaultCAWithSetCAName(t *testing.T) {
srv := getServer(rootPort, testdataDir, "", 0, t)
srv.CA.Config.CA.Name = "DefaultCA"
t.Logf("Server configuration: %+v\n", srv.Config)

// Starting server with two cas with same name
err := srv.Start()
if err != nil {
t.Fatal("Failed to start server:", err)
}

// No ca name specified should sent to default CA 'ca'
client := getRootClient()
_, err = client.Enroll(&api.EnrollmentRequest{
Name: "admin",
Secret: "adminpw",
})
if err != nil {
t.Error("Failed to enroll, error: ", err)
}

err = srv.Stop()
if err != nil {
t.Error("Failed to stop server:", err)
}
}

func TestMultiCAWithIntermediate(t *testing.T) {
srv := getServer(rootPort, testdataDir, "", 0, t)
srv.Config.CAfiles = []string{"ca/rootca/ca1/fabric-ca-server-config.yaml", "ca/rootca/ca2/fabric-ca-server-config.yaml"}
Expand Down
1 change: 1 addition & 0 deletions lib/serverauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ func (ah *fcaAuthHandler) serveHTTP(w http.ResponseWriter, r *http.Request) erro

if req.CAName == "" {
log.Debugf("Directing traffic to default CA")
req.CAName = ah.server.CA.Config.CA.Name
} else {
log.Debugf("Directing traffic to CA %s", req.CAName)
}
Expand Down

0 comments on commit ac8695b

Please sign in to comment.