Skip to content

Commit 185d06e

Browse files
committed
[FAB-3307] Adding Identity Validation
This change-set does the following: 1. It ensures that the MSP's SatisfiesPrincipal function checks validity of the principal identity under the MSP of the principal. Change-Id: I99e42be49a53a06e7743ee48221b3e915bd95c30 Signed-off-by: Angelo De Caro <[email protected]>
1 parent a97886a commit 185d06e

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

msp/mspimpl.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ func (msp *bccspmsp) SatisfiesPrincipal(id Identity, principal *m.MSPPrincipal)
629629
}
630630

631631
if bytes.Equal(id.(*identity).cert.Raw, principalId.(*identity).cert.Raw) {
632-
return nil
632+
return principalId.Validate()
633633
}
634634

635635
return errors.New("The identities do not match")

msp/revocation_test.go

+25-1
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ package msp
1919
import (
2020
"testing"
2121

22+
"github.com/hyperledger/fabric/protos/msp"
2223
"github.com/stretchr/testify/assert"
2324
)
2425

25-
func TestRevocation(t *testing.T) {
26+
func getRevocationMSP(t *testing.T) MSP {
2627
// testdata/revocation
2728
// 1) a key and a signcert (used to populate the default signing identity);
2829
// 2) cacert is the CA that signed the intermediate;
@@ -36,10 +37,33 @@ func TestRevocation(t *testing.T) {
3637
err = thisMSP.Setup(conf)
3738
assert.NoError(t, err)
3839

40+
return thisMSP
41+
}
42+
43+
func TestRevocation(t *testing.T) {
44+
thisMSP := getRevocationMSP(t)
45+
3946
id, err := thisMSP.GetDefaultSigningIdentity()
4047
assert.NoError(t, err)
4148

4249
// the certificate associated to this id is revoked and so validation should fail!
4350
err = id.Validate()
4451
assert.Error(t, err)
4552
}
53+
54+
func TestIdentityPolicyPrincipalAgainstRevokedIdentity(t *testing.T) {
55+
thisMSP := getRevocationMSP(t)
56+
57+
id, err := thisMSP.GetDefaultSigningIdentity()
58+
assert.NoError(t, err)
59+
60+
idSerialized, err := id.Serialize()
61+
assert.NoError(t, err)
62+
63+
principal := &msp.MSPPrincipal{
64+
PrincipalClassification: msp.MSPPrincipal_IDENTITY,
65+
Principal: idSerialized}
66+
67+
err = id.SatisfiesPrincipal(principal)
68+
assert.Error(t, err)
69+
}

0 commit comments

Comments
 (0)