Skip to content

Commit

Permalink
[FAB-8548] Fix CA started with wrong cert path
Browse files Browse the repository at this point in the history
Although CA cert file was specified in arguments and it was
the wrong path, key and certification files were generated
and fabric-ca-server starts successfully.
This patch informs the cert file path does not exist.

Change-Id: I1ea8aab95f61024233d904c695b8af19279c9860
Signed-off-by: Nao Nishijima <[email protected]>
  • Loading branch information
Nao Nishijima committed Jun 8, 2018
1 parent b28fdfd commit 260e1c3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/ca.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ func (ca *CA) initKeyMaterial(renew bool) error {
}
return nil
}
log.Warning(newServerError(ErrCACertFileNotFound, "The specified CA certificate file %s does not exist", certFile))
}

// Get the CA cert
Expand Down
22 changes: 19 additions & 3 deletions lib/servererror.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,8 @@ const (
ErrGettingCert = 67
// Error occurred parsing variable as an integer
ErrParsingIntEnvVar = 68
// CA certificate file is not found warning message
ErrCACertFileNotFound = 69
)

// Construct a new HTTP error.
Expand Down Expand Up @@ -243,19 +245,33 @@ func (he *httpErr) writeResponse(w http.ResponseWriter) error {
return nil
}

type fatalErr struct {
type serverErr struct {
code int
msg string
}

func newFatalError(code int, format string, args ...interface{}) *fatalErr {
type fatalErr struct {
serverErr
}

func newServerError(code int, format string, args ...interface{}) *serverErr {
msg := fmt.Sprintf(format, args...)
return &fatalErr{
return &serverErr{
code: code,
msg: msg,
}
}

func newFatalError(code int, format string, args ...interface{}) *fatalErr {
msg := fmt.Sprintf(format, args...)
return &fatalErr{
serverErr{
code: code,
msg: msg,
},
}
}

func (fe *fatalErr) Error() string {
return fe.String()
}
Expand Down

0 comments on commit 260e1c3

Please sign in to comment.