@@ -7,9 +7,6 @@ SPDX-License-Identifier: Apache-2.0
77package configtxgen
88
99import (
10- "crypto/ecdsa"
11- "crypto/x509"
12- "encoding/pem"
1310 "fmt"
1411 "os"
1512
@@ -383,15 +380,6 @@ func NewApplicationGroup(conf *Application) (*cb.ConfigGroup, error) {
383380 addValue (applicationGroup , channelconfig .CapabilitiesValue (conf .Capabilities ), channelconfig .AdminsPolicyKey )
384381 }
385382
386- if len (conf .MetaNamespaceVerificationKeyPath ) > 0 {
387- key , err := getPubKeyFromPem (conf .MetaNamespaceVerificationKeyPath )
388- if err != nil {
389- return nil , errors .Wrapf (err , "error reading metanamespace verification key" )
390- }
391- addValue (applicationGroup ,
392- channelconfig .MetaNamespaceVerificationKeyValue (key ), channelconfig .AdminsPolicyKey )
393- }
394-
395383 for _ , org := range conf .Organizations {
396384 var err error
397385 applicationGroup .Groups [org .Name ], err = NewApplicationOrgGroup (org )
@@ -404,68 +392,6 @@ func NewApplicationGroup(conf *Application) (*cb.ConfigGroup, error) {
404392 return applicationGroup , nil
405393}
406394
407- // getPubKeyFromPem looks for ECDSA public key in PEM file, and returns pem content only with the public key.
408- func getPubKeyFromPem (file string ) ([]byte , error ) {
409- pemContent , err := os .ReadFile (file )
410- if err != nil {
411- return nil , errors .Wrapf (err , "reading from file %s failed" , file )
412- }
413-
414- for {
415- block , rest := pem .Decode (pemContent )
416- if block == nil {
417- break
418- }
419- pemContent = rest
420-
421- logger .Infof ("Reading block [%s] from file: %s" , block .Type , file )
422-
423- key , err := ParseCertificateOrPublicKey (block .Bytes )
424- if err != nil {
425- continue
426- }
427- return pem .EncodeToMemory (& pem.Block {
428- Type : "PUBLIC KEY" ,
429- Bytes : key ,
430- }), nil
431-
432- }
433-
434- return nil , errors .New ("no ECDSA public key in pem file" )
435- }
436-
437- func ParseCertificateOrPublicKey (blockBytes []byte ) ([]byte , error ) {
438- // Try reading certificate
439- cert , err := x509 .ParseCertificate (blockBytes )
440- var publicKey any
441- if err == nil {
442- if cert .PublicKey != nil && cert .PublicKeyAlgorithm == x509 .ECDSA {
443- logger .Info ("Found certificate with ECDSA public key in block" )
444- publicKey = cert .PublicKey
445- }
446- } else {
447- // If fails, try reading public key
448- anyPublicKey , err := x509 .ParsePKIXPublicKey (blockBytes )
449- if err == nil && anyPublicKey != nil {
450- var isECDSA bool
451- publicKey , isECDSA = anyPublicKey .(* ecdsa.PublicKey )
452- if isECDSA {
453- logger .Info ("Found ECDSA public key in block" )
454- }
455- }
456- }
457-
458- if publicKey == nil {
459- return nil , errors .New ("no ECDSA public key in block" )
460- }
461-
462- key , err := x509 .MarshalPKIXPublicKey (publicKey )
463- if err != nil {
464- return nil , errors .Wrapf (err , "marshalling public key from failed" )
465- }
466- return key , nil
467- }
468-
469395// NewApplicationOrgGroup returns an application org component of the channel configuration. It defines the crypto material for the organization
470396// (its MSP) as well as its anchor peers for use by the gossip network. It sets the mod_policy of all elements to "Admins".
471397func NewApplicationOrgGroup (conf * Organization ) (* cb.ConfigGroup , error ) {
0 commit comments