gitee.com/hyperledger/fabric-ca@v2.0.0-alpha+incompatible/lib/serverinfo.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package lib 8 9 import ( 10 "github.com/hyperledger/fabric-ca/lib/common" 11 "github.com/hyperledger/fabric-ca/lib/metadata" 12 ) 13 14 // ServerInfoResponseNet is the response to the GET /cainfo request 15 type ServerInfoResponseNet struct { 16 // CAName is a unique name associated with fabric-ca-server's CA 17 CAName string 18 // Base64 encoding of PEM-encoded certificate chain 19 CAChain string 20 // Base64 encoding of idemix issuer public key 21 IssuerPublicKey string 22 // Version of the server 23 Version string 24 } 25 26 func newCAInfoEndpoint(s *Server) *serverEndpoint { 27 return &serverEndpoint{ 28 Path: "cainfo", 29 Methods: []string{"GET", "POST", "HEAD"}, 30 Handler: cainfoHandler, 31 Server: s, 32 } 33 } 34 35 // Handle is the handler for the GET or POST /cainfo request 36 func cainfoHandler(ctx *serverRequestContextImpl) (interface{}, error) { 37 ca, err := ctx.GetCA() 38 if err != nil { 39 return nil, err 40 } 41 resp := &common.CAInfoResponseNet{} 42 err = ca.fillCAInfo(resp) 43 if err != nil { 44 return nil, err 45 } 46 resp.Version = metadata.GetVersion() 47 return resp, nil 48 }