Skip to content

Commit

Permalink
[FAB-10568] identity config follow up fix
Browse files Browse the repository at this point in the history
- fix to use literals based on previous codereview
comments

Change-Id: I5fab62ad68246fe0e1b9e5c9fd4cfcdce395da9d
Signed-off-by: Sudesh Shetty <[email protected]>
  • Loading branch information
sudeshrshetty committed Jun 8, 2018
1 parent 6599f55 commit aedc226
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 38 deletions.
37 changes: 18 additions & 19 deletions pkg/msp/identityconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,14 @@ func (c *IdentityConfig) loadClientTLSConfig(configEntity *identityConfigEntity)
return errors.WithMessage(err, "failed to load client cert")
}

identityClient := &msp.ClientConfig{}
identityClient.Organization = configEntity.Client.Organization
identityClient.Logging = configEntity.Client.Logging
identityClient.CryptoConfig = configEntity.Client.CryptoConfig
identityClient.CredentialStore = configEntity.Client.CredentialStore
identityClient.TLSKey = configEntity.Client.TLSCerts.Client.Key.Bytes()
identityClient.TLSCert = configEntity.Client.TLSCerts.Client.Cert.Bytes()

c.client = identityClient
c.client = &msp.ClientConfig{
Organization: configEntity.Client.Organization,
Logging: configEntity.Client.Logging,
CryptoConfig: configEntity.Client.CryptoConfig,
CredentialStore: configEntity.Client.CredentialStore,
TLSKey: configEntity.Client.TLSCerts.Client.Key.Bytes(),
TLSCert: configEntity.Client.TLSCerts.Client.Cert.Bytes(),
}

return nil
}
Expand Down Expand Up @@ -288,20 +287,20 @@ func (c *IdentityConfig) loadAllCAConfigs(configEntity *identityConfigEntity) er
}

func (c *IdentityConfig) getMSPCAConfig(caConfig *CAConfig) (*msp.CAConfig, error) {
mspCAConfig := &msp.CAConfig{}
var err error

mspCAConfig.URL = caConfig.URL
mspCAConfig.Registrar = caConfig.Registrar
mspCAConfig.CAName = caConfig.CAName
mspCAConfig.TLSCAClientCert = caConfig.TLSCACerts.Client.Cert.Bytes()
mspCAConfig.TLSCAClientKey = caConfig.TLSCACerts.Client.Key.Bytes()
mspCAConfig.TLSCAServerCerts, err = c.getServerCerts(caConfig)

serverCerts, err := c.getServerCerts(caConfig)
if err != nil {
return nil, err
}

return mspCAConfig, nil
return &msp.CAConfig{
URL: caConfig.URL,
Registrar: caConfig.Registrar,
CAName: caConfig.CAName,
TLSCAClientCert: caConfig.TLSCACerts.Client.Cert.Bytes(),
TLSCAClientKey: caConfig.TLSCACerts.Client.Key.Bytes(),
TLSCAServerCerts: serverCerts,
}, nil
}

func (c *IdentityConfig) getServerCerts(caConfig *CAConfig) ([][]byte, error) {
Expand Down
38 changes: 19 additions & 19 deletions test/integration/e2e/configless/identityconfig_override_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,14 @@ type exampleClient struct {

func (m *exampleClient) Client() *msp.ClientConfig {

mspClient := &msp.ClientConfig{}
mspClient.Organization = strings.ToLower(client.Organization)
mspClient.Logging = client.Logging
mspClient.CredentialStore = client.CredentialStore
mspClient.CryptoConfig = client.CryptoConfig
mspClient.TLSCert = client.TLSCerts.Client.Cert.Bytes()
mspClient.TLSKey = client.TLSCerts.Client.Key.Bytes()

return mspClient
return &msp.ClientConfig{
Organization: strings.ToLower(client.Organization),
Logging: client.Logging,
CryptoConfig: client.CryptoConfig,
CredentialStore: client.CredentialStore,
TLSKey: client.TLSCerts.Client.Key.Bytes(),
TLSCert: client.TLSCerts.Client.Cert.Bytes(),
}
}

type exampleCaConfig struct{}
Expand All @@ -65,20 +64,21 @@ func (m *exampleCaConfig) CAConfig(org string) (*msp.CAConfig, bool) {
}

func getMSPCAConfig(caConfig *caConfig) (*msp.CAConfig, error) {
mspCAConfig := &msp.CAConfig{}
var err error

mspCAConfig.URL = caConfig.URL
mspCAConfig.Registrar = caConfig.Registrar
mspCAConfig.CAName = caConfig.CAName
mspCAConfig.TLSCAClientCert = caConfig.TLSCACerts.Client.Cert.Bytes()
mspCAConfig.TLSCAClientKey = caConfig.TLSCACerts.Client.Key.Bytes()
mspCAConfig.TLSCAServerCerts, err = getServerCerts(caConfig)

serverCerts, err := getServerCerts(caConfig)
if err != nil {
return nil, err
}

return mspCAConfig, nil
return &msp.CAConfig{
URL: caConfig.URL,
Registrar: caConfig.Registrar,
CAName: caConfig.CAName,
TLSCAClientCert: caConfig.TLSCACerts.Client.Cert.Bytes(),
TLSCAClientKey: caConfig.TLSCACerts.Client.Key.Bytes(),
TLSCAServerCerts: serverCerts,
}, nil

}

func getServerCerts(caConfig *caConfig) ([][]byte, error) {
Expand Down

0 comments on commit aedc226

Please sign in to comment.