-
Notifications
You must be signed in to change notification settings - Fork 0
/
sdk.patch
322 lines (311 loc) · 11.4 KB
/
sdk.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
diff --git a/certstore/identities.pb.go b/certstore/identities.pb.go
new file mode 100644
index 00000000..fca35c34
--- /dev/null
+++ b/certstore/identities.pb.go
@@ -0,0 +1,96 @@
+// Code generated by protoc-gen-go. DO NOT EDIT.
+// source: identities.proto
+
+package certstore
+
+import (
+ fmt "fmt"
+ proto "github.com/golang/protobuf/proto"
+ math "math"
+)
+
+// Reference imports to suppress errors if they are not otherwise used.
+var _ = proto.Marshal
+var _ = fmt.Errorf
+var _ = math.Inf
+
+// This is a compile-time assertion to ensure that this generated file
+// is compatible with the proto package it is being compiled against.
+// A compilation error at this line likely means your copy of the
+// proto package needs to be updated.
+const _ = proto.ProtoPackageIsVersion3 // please upgrade the proto package
+
+type SerializedIdentityWithRef struct {
+ Mspid string `protobuf:"bytes,1,opt,name=mspid,proto3" json:"mspid,omitempty"`
+ IdBytes []byte `protobuf:"bytes,2,opt,name=id_bytes,json=idBytes,proto3" json:"id_bytes,omitempty"`
+ IdRef []byte `protobuf:"bytes,3,opt,name=id_ref,json=idRef,proto3" json:"id_ref,omitempty"`
+ XXX_NoUnkeyedLiteral struct{} `json:"-"`
+ XXX_unrecognized []byte `json:"-"`
+ XXX_sizecache int32 `json:"-"`
+}
+
+func (m *SerializedIdentityWithRef) Reset() { *m = SerializedIdentityWithRef{} }
+func (m *SerializedIdentityWithRef) String() string { return proto.CompactTextString(m) }
+func (*SerializedIdentityWithRef) ProtoMessage() {}
+func (*SerializedIdentityWithRef) Descriptor() ([]byte, []int) {
+ return fileDescriptor_0bb899f6f31212f0, []int{0}
+}
+
+func (m *SerializedIdentityWithRef) XXX_Unmarshal(b []byte) error {
+ return xxx_messageInfo_SerializedIdentityWithRef.Unmarshal(m, b)
+}
+func (m *SerializedIdentityWithRef) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
+ return xxx_messageInfo_SerializedIdentityWithRef.Marshal(b, m, deterministic)
+}
+func (m *SerializedIdentityWithRef) XXX_Merge(src proto.Message) {
+ xxx_messageInfo_SerializedIdentityWithRef.Merge(m, src)
+}
+func (m *SerializedIdentityWithRef) XXX_Size() int {
+ return xxx_messageInfo_SerializedIdentityWithRef.Size(m)
+}
+func (m *SerializedIdentityWithRef) XXX_DiscardUnknown() {
+ xxx_messageInfo_SerializedIdentityWithRef.DiscardUnknown(m)
+}
+
+var xxx_messageInfo_SerializedIdentityWithRef proto.InternalMessageInfo
+
+func (m *SerializedIdentityWithRef) GetMspid() string {
+ if m != nil {
+ return m.Mspid
+ }
+ return ""
+}
+
+func (m *SerializedIdentityWithRef) GetIdBytes() []byte {
+ if m != nil {
+ return m.IdBytes
+ }
+ return nil
+}
+
+func (m *SerializedIdentityWithRef) GetIdRef() []byte {
+ if m != nil {
+ return m.IdRef
+ }
+ return nil
+}
+
+func init() {
+ proto.RegisterType((*SerializedIdentityWithRef)(nil), "certstore.SerializedIdentityWithRef")
+}
+
+func init() { proto.RegisterFile("identities.proto", fileDescriptor_0bb899f6f31212f0) }
+
+var fileDescriptor_0bb899f6f31212f0 = []byte{
+ // 146 bytes of a gzipped FileDescriptorProto
+ 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0xc8, 0x4c, 0x49, 0xcd,
+ 0x2b, 0xc9, 0x2c, 0xc9, 0x4c, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4c, 0x4e,
+ 0x2d, 0x2a, 0x29, 0x2e, 0xc9, 0x2f, 0x4a, 0x55, 0x4a, 0xe6, 0x92, 0x0c, 0x4e, 0x2d, 0xca, 0x4c,
+ 0xcc, 0xc9, 0xac, 0x4a, 0x4d, 0xf1, 0x84, 0x28, 0xac, 0x0c, 0xcf, 0x2c, 0xc9, 0x08, 0x4a, 0x4d,
+ 0x13, 0x12, 0xe1, 0x62, 0xcd, 0x2d, 0x2e, 0xc8, 0x4c, 0x91, 0x60, 0x54, 0x60, 0xd4, 0xe0, 0x0c,
+ 0x82, 0x70, 0x84, 0x24, 0xb9, 0x38, 0x32, 0x53, 0xe2, 0x93, 0x2a, 0x4b, 0x52, 0x8b, 0x25, 0x98,
+ 0x14, 0x18, 0x35, 0x78, 0x82, 0xd8, 0x33, 0x53, 0x9c, 0x40, 0x5c, 0x21, 0x51, 0x2e, 0xb6, 0xcc,
+ 0x94, 0xf8, 0xa2, 0xd4, 0x34, 0x09, 0x66, 0xb0, 0x04, 0x6b, 0x66, 0x4a, 0x50, 0x6a, 0x5a, 0x12,
+ 0x1b, 0xd8, 0x5a, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0x57, 0x2f, 0x9e, 0xff, 0x8a, 0x00,
+ 0x00, 0x00,
+}
diff --git a/certstore/identities.proto b/certstore/identities.proto
new file mode 100644
index 00000000..8b203804
--- /dev/null
+++ b/certstore/identities.proto
@@ -0,0 +1,9 @@
+syntax = "proto3";
+package certstore;
+
+message SerializedIdentityWithRef {
+ string mspid = 1;
+ bytes id_bytes = 2;
+ bytes id_ref = 3;
+}
+
diff --git a/certstore/main.go b/certstore/main.go
new file mode 100644
index 00000000..e8658d83
--- /dev/null
+++ b/certstore/main.go
@@ -0,0 +1,39 @@
+package certstore
+
+import (
+ "context"
+ "crypto/sha256"
+ "github.com/golang/protobuf/proto"
+ contextImpl "github.com/hyperledger/fabric-sdk-go/pkg/context"
+ "github.com/hyperledger/fabric/common/flogging"
+)
+
+var logger = flogging.MustGetLogger("certstor")
+
+func MakeCreatorAndCert(ctx context.Context) ([]byte, []byte) {
+ cctx, ok := contextImpl.RequestClientContext(ctx)
+ if !ok {
+ logger.Warn("ctx isn't context.Client")
+ return nil, nil
+ }
+ creator, err := cctx.Serialize()
+ if err != nil {
+ logger.Warn(err)
+ return nil, nil
+ }
+ sId := &SerializedIdentityWithRef{}
+ if err := proto.Unmarshal(creator, sId); err != nil {
+ logger.Warn(err)
+ return nil, nil
+ }
+ id := sha256.Sum256(sId.IdBytes)
+ sId.IdRef = id[:]
+ cert := sId.IdBytes
+ sId.IdBytes = nil
+ if creator, err = proto.Marshal(sId); err != nil {
+ logger.Warn(err)
+ return nil, nil
+ }
+ return creator, cert
+}
+
diff --git a/pkg/client/channel/api.go b/pkg/client/channel/api.go
index effd8c83..f1188c87 100644
--- a/pkg/client/channel/api.go
+++ b/pkg/client/channel/api.go
@@ -29,6 +29,7 @@ type requestOptions struct {
Timeouts map[fab.TimeoutType]time.Duration //timeout options for channel client operations
ParentContext reqContext.Context //parent grpc context for channel client operations (query, execute, invokehandler)
CCFilter invoke.CCFilter
+ WithoutCert bool
}
// RequestOption func for each Opts argument
@@ -163,3 +164,10 @@ func WithChaincodeFilter(ccFilter invoke.CCFilter) RequestOption {
return nil
}
}
+
+func WithoutCert() RequestOption {
+ return func(ctx context.Client, o *requestOptions) error {
+ o.WithoutCert = true
+ return nil
+ }
+}
diff --git a/pkg/client/channel/invoke/api.go b/pkg/client/channel/invoke/api.go
index 6157317f..d6324ad8 100644
--- a/pkg/client/channel/invoke/api.go
+++ b/pkg/client/channel/invoke/api.go
@@ -32,6 +32,7 @@ type Opts struct {
Timeouts map[fab.TimeoutType]time.Duration
ParentContext reqContext.Context //parent grpc context
CCFilter CCFilter
+ WithoutCert bool
}
// Request contains the parameters to execute transaction
diff --git a/pkg/client/channel/invoke/txnhandler.go b/pkg/client/channel/invoke/txnhandler.go
index 83badef2..b92fd3e2 100644
--- a/pkg/client/channel/invoke/txnhandler.go
+++ b/pkg/client/channel/invoke/txnhandler.go
@@ -9,6 +9,8 @@ package invoke
import (
"bytes"
+ "github.com/hyperledger/fabric-sdk-go/certstore"
+
"github.com/hyperledger/fabric-sdk-go/pkg/common/errors/status"
"github.com/hyperledger/fabric-sdk-go/pkg/common/options"
"github.com/pkg/errors"
@@ -45,6 +47,17 @@ func (e *EndorsementHandler) Handle(requestContext *RequestContext, clientContex
TxnHeaderOpts = e.headerOptsProvider()
}
+ if requestContext.Opts.WithoutCert {
+ creator, cert := certstore.MakeCreatorAndCert(requestContext.Ctx)
+ if creator != nil && cert != nil {
+ TxnHeaderOpts = append(TxnHeaderOpts, fab.WithCreator(creator))
+ if requestContext.Request.TransientMap == nil {
+ requestContext.Request.TransientMap = make(map[string][]byte)
+ }
+ requestContext.Request.TransientMap["cert"] = cert
+ }
+ }
+
transactionProposalResponses, proposal, err := createAndSendTransactionProposal(
clientContext.Transactor,
&requestContext.Request,
diff --git a/pkg/client/channel/invoke/signature.go b/pkg/client/channel/invoke/signature.go
index bc7ab397..bc545c07 100644
--- a/pkg/client/channel/invoke/signature.go
+++ b/pkg/client/channel/invoke/signature.go
@@ -9,8 +9,6 @@ package invoke
import (
"github.com/hyperledger/fabric-sdk-go/pkg/client/common/verifier"
"github.com/hyperledger/fabric-sdk-go/pkg/common/providers/fab"
-
- "github.com/pkg/errors"
)
//NewSignatureValidationHandler returns a handler that validates an endorsement
@@ -26,11 +24,11 @@ type SignatureValidationHandler struct {
//Handle for Filtering proposal response
func (f *SignatureValidationHandler) Handle(requestContext *RequestContext, clientContext *ClientContext) {
//Filter tx proposal responses
- err := f.validate(requestContext.Response.Responses, clientContext)
- if err != nil {
- requestContext.Error = errors.WithMessage(err, "signature validation failed")
- return
- }
+ //err := f.validate(requestContext.Response.Responses, clientContext)
+ //if err != nil {
+ // requestContext.Error = errors.WithMessage(err, "signature validation failed")
+ // return
+ //}
// Delegate to next step if any
if f.next != nil {
diff --git a/pkg/client/channel/invoke/txnhandler.go b/pkg/client/channel/invoke/txnhandler.go
index 83badef2..0324b5c2 100644
--- a/pkg/client/channel/invoke/txnhandler.go
+++ b/pkg/client/channel/invoke/txnhandler.go
@@ -124,11 +124,11 @@ type EndorsementValidationHandler struct {
func (f *EndorsementValidationHandler) Handle(requestContext *RequestContext, clientContext *ClientContext) {
//Filter tx proposal responses
- err := f.validate(requestContext.Response.Responses)
- if err != nil {
- requestContext.Error = errors.WithMessage(err, "endorsement validation failed")
- return
- }
+ //err := f.validate(requestContext.Response.Responses)
+ //if err != nil {
+ // requestContext.Error = errors.WithMessage(err, "endorsement validation failed")
+ // return
+ //}
//Delegate to next step if any
if f.next != nil {
diff --git a/pkg/client/resmgmt/resmgmt.go b/pkg/client/resmgmt/resmgmt.go
index 3f061c20..341f39c1 100644
--- a/pkg/client/resmgmt/resmgmt.go
+++ b/pkg/client/resmgmt/resmgmt.go
@@ -823,10 +823,10 @@ func (rc *Client) sendCCProposal(reqCtx reqContext.Context, ccProposalType chain
}
// Verify signature(s)
- err = rc.verifyTPSignature(channelService, txProposalResponse)
- if err != nil {
- return tp.TxnID, errors.WithMessage(err, "sending deploy transaction proposal failed to verify signature")
- }
+ //err = rc.verifyTPSignature(channelService, txProposalResponse)
+ //if err != nil {
+ // return tp.TxnID, errors.WithMessage(err, "sending deploy transaction proposal failed to verify signature")
+ //}
eventService, err := channelService.EventService()
if err != nil {
diff --git a/pkg/fab/channel/ledger.go b/pkg/fab/channel/ledger.go
index b0edfa4c..9d098550 100644
--- a/pkg/fab/channel/ledger.go
+++ b/pkg/fab/channel/ledger.go
@@ -278,12 +278,12 @@ func filterResponses(responses []*fab.TransactionProposalResponse, errs error, v
filteredResponses := responses[:0]
for _, response := range responses {
if response.Status == http.StatusOK {
- if verifier != nil {
- if err := verifier.Verify(response); err != nil {
- errs = multi.Append(errs, errors.Errorf("failed to verify response from %s: %s", response.Endorser, err))
- continue
- }
- }
+ //if verifier != nil {
+ // if err := verifier.Verify(response); err != nil {
+ // errs = multi.Append(errs, errors.Errorf("failed to verify response from %s: %s", response.Endorser, err))
+ // continue
+ // }
+ //}
filteredResponses = append(filteredResponses, response)
} else {
errs = multi.Append(errs, errors.Errorf("bad status from %s (%d)", response.Endorser, response.Status))