@@ -25,6 +25,7 @@ import (
25
25
"io"
26
26
27
27
"github.com/hyperledger/fabric/bccsp"
28
+ "github.com/hyperledger/fabric/bccsp/factory"
28
29
"github.com/hyperledger/fabric/common/tools/cryptogen/ca"
29
30
"github.com/hyperledger/fabric/common/tools/cryptogen/csp"
30
31
)
@@ -66,14 +67,31 @@ func GenerateLocalMSP(baseDir, name string, sans []string, rootCA *ca.CA) error
66
67
}
67
68
68
69
// write artifacts to MSP folders
69
- folders := []string {"admincerts" , "cacerts" }
70
+
71
+ // the CA certificate goes into cacerts
72
+ folders := []string {"cacerts" }
70
73
for _ , folder := range folders {
71
74
err = x509Export (filepath .Join (mspDir , folder , x509Filename (rootCA .Name )), rootCA .SignCert )
72
75
if err != nil {
73
76
return err
74
77
}
75
78
}
76
79
80
+ // the signing identity goes into admincerts.
81
+ // This means that the signing identity
82
+ // of this MSP is also an admin of this MSP
83
+ // NOTE: the admincerts folder is going to be
84
+ // cleared up anyway by copyAdminCert, but
85
+ // we leave a valid admin for now for the sake
86
+ // of unit tests
87
+ folders = []string {"admincerts" }
88
+ for _ , folder := range folders {
89
+ err = x509Export (filepath .Join (mspDir , folder , x509Filename (rootCA .Name )), cert )
90
+ if err != nil {
91
+ return err
92
+ }
93
+ }
94
+
77
95
// write artifacts to TLS folder
78
96
err = x509Export (filepath .Join (tlsDir , "ca.crt" ), rootCA .SignCert )
79
97
if err != nil {
@@ -99,7 +117,7 @@ func GenerateVerifyingMSP(baseDir string, rootCA *ca.CA) error {
99
117
err := createFolderStructure (baseDir )
100
118
if err == nil {
101
119
// write MSP cert to appropriate folders
102
- folders := []string {"admincerts" , " cacerts" , "signcerts" }
120
+ folders := []string {"cacerts" , "signcerts" }
103
121
for _ , folder := range folders {
104
122
err = x509Export (filepath .Join (baseDir , folder , x509Filename (rootCA .Name )), rootCA .SignCert )
105
123
if err != nil {
@@ -108,6 +126,22 @@ func GenerateVerifyingMSP(baseDir string, rootCA *ca.CA) error {
108
126
}
109
127
}
110
128
129
+ // create a throwaway cert to act as an admin cert
130
+ // NOTE: the admincerts folder is going to be
131
+ // cleared up anyway by copyAdminCert, but
132
+ // we leave a valid admin for now for the sake
133
+ // of unit tests
134
+ bcsp := factory .GetDefault ()
135
+ priv , err := bcsp .KeyGen (& bccsp.ECDSAP256KeyGenOpts {Temporary : true })
136
+ ecPubKey , err := csp .GetECPublicKey (priv )
137
+ if err != nil {
138
+ return err
139
+ }
140
+ _ , err = rootCA .SignCertificate (filepath .Join (baseDir , "admincerts" ), rootCA .Name , []string {"" }, ecPubKey )
141
+ if err != nil {
142
+ return err
143
+ }
144
+
111
145
return nil
112
146
}
113
147
0 commit comments