Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 5f28e69

Browse files
committed
[FAB-7931] Update to fabric v1.1.0-alpha
Change-Id: Iba54a77cee7c79c952f198a897cb76c749745f53 Signed-off-by: Troy Ronda <troy@troyronda.com>
1 parent 10205b2 commit 5f28e69

29 files changed

+342
-173
lines changed

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ FABRIC_STABLE_VERSION_MINOR := 1.0
3232
FABRIC_STABLE_VERSION_MAJOR := 1
3333
FABRIC_BASEIMAGE_STABLE_VERSION := 0.4.2
3434

35-
FABRIC_PRERELEASE_VERSION := 1.1.0-preview
35+
FABRIC_PRERELEASE_VERSION := 1.1.0-alpha
3636
FABRIC_PREV_VERSION := 1.0.0
3737
FABRIC_DEVSTABLE_VERSION_MINOR := 1.1
3838
FABRIC_DEVSTABLE_VERSION_MAJOR := 1
@@ -63,9 +63,9 @@ FABRIC_DEV_REGISTRY_PRE_CMD ?= docker login -u docker -p docker nexus3.hyperledg
6363

6464
# Upstream fabric patching (overridable)
6565
THIRDPARTY_FABRIC_CA_BRANCH ?= master
66-
THIRDPARTY_FABRIC_CA_COMMIT ?= v1.1.0-preview
66+
THIRDPARTY_FABRIC_CA_COMMIT ?= 437d27e179fa1ed18940af88267d4e19df6dc175
6767
THIRDPARTY_FABRIC_BRANCH ?= master
68-
THIRDPARTY_FABRIC_COMMIT ?= a58d8f4446767054965ecefe42035da17429973d
68+
THIRDPARTY_FABRIC_COMMIT ?= v1.1.0-alpha
6969

7070
# Force removal of images in cleanup (overridable)
7171
FIXTURE_DOCKER_REMOVE_FORCE ?= false

api/apifabca/fabricca.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ package apifabca
88

99
import (
1010
"github.com/hyperledger/fabric-sdk-go/api/apicryptosuite"
11+
api "github.com/hyperledger/fabric-sdk-go/internal/github.com/hyperledger/fabric-ca/api"
1112
)
1213

1314
// FabricCAClient is the client interface for fabric-ca
@@ -17,7 +18,7 @@ type FabricCAClient interface {
1718
// Reenroll to renew user's enrollment certificate
1819
Reenroll(user User) (apicryptosuite.Key, []byte, error)
1920
Register(registrar User, request *RegistrationRequest) (string, error)
20-
Revoke(registrar User, request *RevocationRequest) error
21+
Revoke(registrar User, request *RevocationRequest) (*api.RevocationResponse, error)
2122
}
2223

2324
// RegistrationRequest defines the attributes required to register a user with the CA

internal/github.com/hyperledger/fabric-ca/api/client.go

Lines changed: 188 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Please review third_party pinning scripts and patches for more details.
2121
package api
2222

2323
import (
24+
"math/big"
2425
"time"
2526

2627
"github.com/cloudflare/cfssl/csr"
@@ -32,7 +33,7 @@ type RegistrationRequest struct {
3233
// Name is the unique name of the identity
3334
Name string `json:"id" help:"Unique name of the identity"`
3435
// Type of identity being registered (e.g. "peer, app, user")
35-
Type string `json:"type" def:"user" help:"Type of identity being registered (e.g. 'peer, app, user')"`
36+
Type string `json:"type" def:"client" help:"Type of identity being registered (e.g. 'peer, app, user')"`
3637
// Secret is an optional password. If not specified,
3738
// a random secret is generated. In both cases, the secret
3839
// is returned in the RegistrationResponse.
@@ -119,6 +120,61 @@ type RevocationRequest struct {
119120
Reason string `json:"reason,omitempty" opt:"r" help:"Reason for revocation"`
120121
// CAName is the name of the CA to connect to
121122
CAName string `json:"caname,omitempty" skip:"true"`
123+
// GenCRL specifies whether to generate a CRL
124+
GenCRL bool `def:"false" skip:"true" json:"gencrl,omitempty"`
125+
}
126+
127+
// RevocationResponse represents response from the server for a revocation request
128+
type RevocationResponse struct {
129+
// RevokedCerts is an array of certificates that were revoked
130+
RevokedCerts []RevokedCert
131+
// CRL is PEM-encoded certificate revocation list (CRL) that contains all unexpired revoked certificates
132+
CRL []byte
133+
}
134+
135+
// RevokedCert represents a revoked certificate
136+
type RevokedCert struct {
137+
// Serial number of the revoked certificate
138+
Serial string
139+
// AKI of the revoked certificate
140+
AKI string
141+
}
142+
143+
// GetTCertBatchRequest is input provided to identity.GetTCertBatch
144+
type GetTCertBatchRequest struct {
145+
// Number of TCerts in the batch.
146+
Count int `json:"count"`
147+
// The attribute names whose names and values are to be sealed in the issued TCerts.
148+
AttrNames []string `json:"attr_names,omitempty"`
149+
// EncryptAttrs denotes whether to encrypt attribute values or not.
150+
// When set to true, each issued TCert in the batch will contain encrypted attribute values.
151+
EncryptAttrs bool `json:"encrypt_attrs,omitempty"`
152+
// Certificate Validity Period. If specified, the value used
153+
// is the minimum of this value and the configured validity period
154+
// of the TCert manager.
155+
ValidityPeriod time.Duration `json:"validity_period,omitempty"`
156+
// The pre-key to be used for key derivation.
157+
PreKey string `json:"prekey"`
158+
// DisableKeyDerivation if true disables key derivation so that a TCert is not
159+
// cryptographically related to an ECert. This may be necessary when using an
160+
// HSM which does not support the TCert's key derivation function.
161+
DisableKeyDerivation bool `json:"disable_kdf,omitempty"`
162+
// CAName is the name of the CA to connect to
163+
CAName string `json:"caname,omitempty" skip:"true"`
164+
}
165+
166+
// GetTCertBatchResponse is the return value of identity.GetTCertBatch
167+
type GetTCertBatchResponse struct {
168+
ID *big.Int `json:"id"`
169+
TS time.Time `json:"ts"`
170+
Key []byte `json:"key"`
171+
TCerts []TCert `json:"tcerts"`
172+
}
173+
174+
// TCert encapsulates a signed transaction certificate and optionally a map of keys
175+
type TCert struct {
176+
Cert []byte `json:"cert"`
177+
Keys map[string][]byte `json:"keys,omitempty"` //base64 encoded string as value
122178
}
123179

124180
// GetCAInfoRequest is request to get generic CA information
@@ -137,17 +193,134 @@ type GenCRLRequest struct {
137193

138194
// GenCRLResponse represents a response to get CRL
139195
type GenCRLResponse struct {
140-
CRL string
196+
// CRL is PEM-encoded certificate revocation list (CRL) that contains requested unexpired revoked certificates
197+
CRL []byte
198+
}
199+
200+
// AddIdentityRequest represents the request to add a new identity to the
201+
// fabric-ca-server
202+
type AddIdentityRequest struct {
203+
ID string `json:"id" skip:"true"`
204+
Type string `json:"type" def:"user" help:"Type of identity being registered (e.g. 'peer, app, user')"`
205+
Affiliation string `json:"affiliation" help:"The identity's affiliation"`
206+
Attributes []Attribute `json:"attrs" mapstructure:"attrs" `
207+
MaxEnrollments int `json:"max_enrollments" mapstructure:"max_enrollments" def:"-1" help:"The maximum number of times the secret can be reused to enroll."`
208+
// Secret is an optional password. If not specified,
209+
// a random secret is generated. In both cases, the secret
210+
// is returned in the RegistrationResponse.
211+
Secret string `json:"secret,omitempty" mask:"password" help:"The enrollment secret for the identity being added"`
212+
CAName string `json:"caname,omitempty" skip:"true"`
213+
}
214+
215+
// ModifyIdentityRequest represents the request to modify an existing identity on the
216+
// fabric-ca-server
217+
type ModifyIdentityRequest struct {
218+
ID string `skip:"true"`
219+
Type string `json:"type" def:"user" help:"Type of identity being registered (e.g. 'peer, app, user')"`
220+
Affiliation string `json:"affiliation" help:"The identity's affiliation"`
221+
Attributes []Attribute `mapstructure:"attrs" json:"attrs"`
222+
MaxEnrollments int `mapstructure:"max_enrollments" json:"max_enrollments" def:"-1" help:"The maximum number of times the secret can be reused to enroll."`
223+
Secret string `json:"secret,omitempty" mask:"password" help:"The enrollment secret for the identity"`
224+
CAName string `json:"caname,omitempty" skip:"true"`
225+
}
226+
227+
// RemoveIdentityRequest represents the request to remove an existing identity from the
228+
// fabric-ca-server
229+
type RemoveIdentityRequest struct {
230+
ID string `skip:"true"`
231+
Force bool `json:"force"`
232+
CAName string `json:"caname,omitempty" skip:"true"`
233+
}
234+
235+
// GetIDResponse is the response from the GetIdentity call
236+
type GetIDResponse struct {
237+
ID string `json:"id" skip:"true"`
238+
Type string `json:"type" def:"user"`
239+
Affiliation string `json:"affiliation"`
240+
Attributes []Attribute `json:"attrs" mapstructure:"attrs" `
241+
MaxEnrollments int `json:"max_enrollments" mapstructure:"max_enrollments"`
242+
CAName string `json:"caname,omitempty"`
243+
}
244+
245+
// GetAllIDsResponse is the response from the GetAllIdentities call
246+
type GetAllIDsResponse struct {
247+
Identities []IdentityInfo `json:"identities"`
248+
CAName string `json:"caname,omitempty"`
249+
}
250+
251+
// IdentityResponse is the response from the any add/modify/remove identity call
252+
type IdentityResponse struct {
253+
ID string `json:"id" skip:"true"`
254+
Type string `json:"type,omitempty"`
255+
Affiliation string `json:"affiliation"`
256+
Attributes []Attribute `json:"attrs,omitempty" mapstructure:"attrs"`
257+
MaxEnrollments int `json:"max_enrollments,omitempty" mapstructure:"max_enrollments"`
258+
Secret string `json:"secret,omitempty"`
259+
CAName string `json:"caname,omitempty"`
260+
}
261+
262+
// IdentityInfo contains information about an identity
263+
type IdentityInfo struct {
264+
ID string `json:"id"`
265+
Type string `json:"type"`
266+
Affiliation string `json:"affiliation"`
267+
Attributes []Attribute `json:"attrs" mapstructure:"attrs"`
268+
MaxEnrollments int `json:"max_enrollments" mapstructure:"max_enrollments"`
269+
}
270+
271+
// AddAffiliationRequest represents the request to add a new affiliation to the
272+
// fabric-ca-server
273+
type AddAffiliationRequest struct {
274+
Name string `json:"name"`
275+
Force bool `json:"force"`
276+
CAName string `json:"caname,omitempty"`
277+
}
278+
279+
// ModifyAffiliationRequest represents the request to modify an existing affiliation on the
280+
// fabric-ca-server
281+
type ModifyAffiliationRequest struct {
282+
Name string
283+
NewName string `json:"name"`
284+
Force bool `json:"force"`
285+
CAName string `json:"caname,omitempty"`
286+
}
287+
288+
// RemoveAffiliationRequest represents the request to remove an existing affiliation from the
289+
// fabric-ca-server
290+
type RemoveAffiliationRequest struct {
291+
Name string
292+
Force bool `json:"force"`
293+
CAName string `json:"caname,omitempty"`
294+
}
295+
296+
// AffiliationResponse contains the response for get, add, modify, and remove an affiliation
297+
type AffiliationResponse struct {
298+
AffiliationInfo `mapstructure:",squash"`
299+
CAName string `json:"caname,omitempty"`
300+
}
301+
302+
// AffiliationInfo contains the affiliation name, child affiliation info, and identities
303+
// associated with this affiliation.
304+
type AffiliationInfo struct {
305+
Name string `json:"name"`
306+
Affiliations []AffiliationInfo `json:"affiliations,omitempty"`
307+
Identities []IdentityInfo `json:"identities,omitempty"`
141308
}
142309

143310
// CSRInfo is Certificate Signing Request (CSR) Information
144311
type CSRInfo struct {
145-
CN string `json:"CN"`
146-
Names []csr.Name `json:"names,omitempty"`
147-
Hosts []string `json:"hosts,omitempty"`
148-
KeyRequest *csr.BasicKeyRequest `json:"key,omitempty"`
149-
CA *csr.CAConfig `json:"ca,omitempty"`
150-
SerialNumber string `json:"serial_number,omitempty"`
312+
CN string `json:"CN"`
313+
Names []csr.Name `json:"names,omitempty"`
314+
Hosts []string `json:"hosts,omitempty"`
315+
KeyRequest *BasicKeyRequest `json:"key,omitempty"`
316+
CA *csr.CAConfig `json:"ca,omitempty"`
317+
SerialNumber string `json:"serial_number,omitempty"`
318+
}
319+
320+
// BasicKeyRequest encapsulates size and algorithm for the key to be generated
321+
type BasicKeyRequest struct {
322+
Algo string `json:"algo" yaml:"algo"`
323+
Size int `json:"size" yaml:"size"`
151324
}
152325

153326
// Attribute is a name and value pair
@@ -183,3 +356,10 @@ func (ar *AttributeRequest) GetName() string {
183356
func (ar *AttributeRequest) IsRequired() bool {
184357
return !ar.Optional
185358
}
359+
360+
// NewBasicKeyRequest returns the BasicKeyRequest object that is constructed
361+
// from the object returned by the csr.NewBasicKeyRequest() function
362+
func NewBasicKeyRequest() *BasicKeyRequest {
363+
bkr := csr.NewBasicKeyRequest()
364+
return &BasicKeyRequest{Algo: bkr.A, Size: bkr.S}
365+
}

internal/github.com/hyperledger/fabric-ca/api/net.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,40 @@ type RevocationRequestNet struct {
6565
RevocationRequest
6666
}
6767

68+
// GetTCertBatchRequestNet is a network request for a batch of transaction certificates
69+
type GetTCertBatchRequestNet struct {
70+
GetTCertBatchRequest
71+
// KeySigs is an optional array of public keys and corresponding signatures.
72+
// If not set, the server generates it's own keys based on a key derivation function
73+
// which cryptographically relates the TCerts to an ECert.
74+
KeySigs []KeySig `json:"key_sigs,omitempty"`
75+
}
76+
77+
// GetTCertBatchResponseNet is the network response for a batch of transaction certificates
78+
type GetTCertBatchResponseNet struct {
79+
GetTCertBatchResponse
80+
}
81+
82+
// AddIdentityRequestNet is a network request for adding a new identity
83+
type AddIdentityRequestNet struct {
84+
AddIdentityRequest
85+
}
86+
87+
// ModifyIdentityRequestNet is a network request for modifying an existing identity
88+
type ModifyIdentityRequestNet struct {
89+
ModifyIdentityRequest
90+
}
91+
92+
// AddAffiliationRequestNet is a network request for adding a new affiliation
93+
type AddAffiliationRequestNet struct {
94+
AddAffiliationRequest
95+
}
96+
97+
// ModifyAffiliationRequestNet is a network request for modifying an existing affiliation
98+
type ModifyAffiliationRequestNet struct {
99+
ModifyAffiliationRequest
100+
}
101+
68102
// KeySig is a public key, signature, and signature algorithm tuple
69103
type KeySig struct {
70104
// Key is a public key

internal/github.com/hyperledger/fabric-ca/lib/client.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ type GetServerInfoResponse struct {
134134
// CAChain is the PEM-encoded bytes of the fabric-ca-server's CA chain.
135135
// The 1st element of the chain is the root CA cert
136136
CAChain []byte
137+
// Version of the server
138+
Version string
137139
}
138140

139141
// Convert from network to local server information
@@ -144,6 +146,7 @@ func (c *Client) net2LocalServerInfo(net *serverInfoResponseNet, local *GetServe
144146
}
145147
local.CAName = net.CAName
146148
local.CAChain = caChain
149+
local.Version = net.Version
147150
return nil
148151
}
149152

@@ -235,7 +238,7 @@ func (c *Client) GenCSR(req *api.CSRInfo, id string) ([]byte, apicryptosuite.Key
235238
cr.CN = id
236239

237240
if cr.KeyRequest == nil {
238-
cr.KeyRequest = csr.NewBasicKeyRequest()
241+
cr.KeyRequest = newCfsslBasicKeyRequest(api.NewBasicKeyRequest())
239242
}
240243

241244
key, cspSigner, err := util.BCCSPKeyRequestGenerate(cr, c.csp)
@@ -271,7 +274,7 @@ func (c *Client) newCertificateRequest(req *api.CSRInfo) *csr.CertificateRequest
271274
}
272275
}
273276
if req != nil && req.KeyRequest != nil {
274-
cr.KeyRequest = req.KeyRequest
277+
cr.KeyRequest = newCfsslBasicKeyRequest(req.KeyRequest)
275278
}
276279
if req != nil {
277280
cr.CA = req.CA
@@ -315,7 +318,7 @@ func (c *Client) SendReq(req *http.Request, result interface{}) (err error) {
315318

316319
resp, err := c.httpClient.Do(req)
317320
if err != nil {
318-
return errors.Wrapf(err, "POST failure of request: %s", reqStr)
321+
return errors.Wrapf(err, "%s failure of request: %s", req.Method, reqStr)
319322
}
320323
var respBody []byte
321324
if resp.Body != nil {
@@ -377,6 +380,10 @@ func (c *Client) getURL(endpoint string) (string, error) {
377380
return rtn, nil
378381
}
379382

383+
func newCfsslBasicKeyRequest(bkr *api.BasicKeyRequest) *csr.BasicKeyRequest {
384+
return &csr.BasicKeyRequest{A: bkr.Algo, S: bkr.Size}
385+
}
386+
380387
// NormalizeURL normalizes a URL (from cfssl)
381388
func NormalizeURL(addr string) (*url.URL, error) {
382389
addr = strings.TrimSpace(addr)

0 commit comments

Comments
 (0)