@@ -68,18 +68,6 @@ func ConfigFromBackend(coreBackend ...core.ConfigBackend) (fab.EndpointConfig, e
6868 return nil , errors .WithMessage (err , "network configuration load failed" )
6969 }
7070
71- config .tlsCertPool = commtls .NewCertPool (config .backend .GetBool ("client.tlsCerts.systemCertPool" ))
72-
73- // preemptively add all TLS certs to cert pool as adding them at request time
74- // is expensive
75- certs , err := config .loadTLSCerts ()
76- if err != nil {
77- logger .Infof ("could not cache TLS certs: %s" , err )
78- }
79- if _ , err := config .TLSCACertPool (certs ... ); err != nil {
80- return nil , errors .WithMessage (err , "cert pool load failed" )
81- }
82-
8371 //print deprecated warning
8472 detectDeprecatedNetworkConfig (config )
8573
@@ -90,7 +78,7 @@ func ConfigFromBackend(coreBackend ...core.ConfigBackend) (fab.EndpointConfig, e
9078type EndpointConfig struct {
9179 backend * lookup.ConfigLookup
9280 networkConfig * fab.NetworkConfig
93- tlsCertPool commtls .CertPool
81+ tlsCertPool fab .CertPool
9482 entityMatchers * entityMatchers
9583 peerConfigsByOrg map [string ][]fab.PeerConfig
9684 networkPeers []fab.NetworkPeer
@@ -103,6 +91,20 @@ type EndpointConfig struct {
10391 channelMatchers map [int ]* regexp.Regexp
10492}
10593
94+ //endpointConfigEntity contains endpoint config elements needed by endpointconfig
95+ type endpointConfigEntity struct {
96+ Client ClientConfig
97+ Channels map [string ]ChannelEndpointConfig
98+ Organizations map [string ]OrganizationConfig
99+ Orderers map [string ]OrdererConfig
100+ Peers map [string ]PeerConfig
101+ }
102+
103+ //entityMatchers for endpoint configuration
104+ type entityMatchers struct {
105+ matchers map [string ][]MatchConfig
106+ }
107+
106108// Timeout reads timeouts for the given timeout type, if type is not found in the config
107109// then default is set as per the const value above for the corresponding type
108110func (c * EndpointConfig ) Timeout (tType fab.TimeoutType ) time.Duration {
@@ -276,8 +278,8 @@ func (c *EndpointConfig) ChannelOrderers(name string) ([]fab.OrdererConfig, bool
276278
277279// TLSCACertPool returns the configured cert pool. If a certConfig
278280// is provided, the certificate is added to the pool
279- func (c * EndpointConfig ) TLSCACertPool (certs ... * x509. Certificate ) ( * x509 .CertPool , error ) {
280- return c .tlsCertPool . Get ( certs ... )
281+ func (c * EndpointConfig ) TLSCACertPool () fab .CertPool {
282+ return c .tlsCertPool
281283}
282284
283285// EventServiceType returns the type of event service client to use
@@ -503,6 +505,12 @@ func (c *EndpointConfig) loadEndpointConfigEntities(configEntity *endpointConfig
503505 return errors .WithMessage (err , "failed to load channel orderers" )
504506 }
505507
508+ //load tls cert pool
509+ err = c .loadTLSCertPool ()
510+ if err != nil {
511+ return errors .WithMessage (err , "failed to load TLS cert pool" )
512+ }
513+
506514 return nil
507515}
508516
@@ -845,6 +853,23 @@ func (c *EndpointConfig) loadChannelOrderers() error {
845853 return nil
846854}
847855
856+ func (c * EndpointConfig ) loadTLSCertPool () error {
857+
858+ c .tlsCertPool = commtls .NewCertPool (c .backend .GetBool ("client.tlsCerts.systemCertPool" ))
859+
860+ // preemptively add all TLS certs to cert pool as adding them at request time
861+ // is expensive
862+ certs , err := c .loadTLSCerts ()
863+ if err != nil {
864+ logger .Infof ("could not cache TLS certs: %s" , err )
865+ }
866+
867+ if _ , err := c .tlsCertPool .Get (certs ... ); err != nil {
868+ return errors .WithMessage (err , "cert pool load failed" )
869+ }
870+ return nil
871+ }
872+
848873// loadTLSClientCerts loads the client's certs for mutual TLS
849874// It checks the config for embedded pem files before looking for cert files
850875func (c * EndpointConfig ) loadTLSClientCerts (configEntity * endpointConfigEntity ) error {
0 commit comments