-
Notifications
You must be signed in to change notification settings - Fork 508
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FABG-961] Use system cert pool when connecting to fabric-ca (#69)
When client.tlsCerts.systemCertPool is set to true, TLS connections to fabric-ca instances now use system cert pool. There is no need to have tlsCACerts.path defined in CAs' configurations in that case. Signed-off-by: Aleksandar Likic <aleksandar.likic@securekey.com>
- Loading branch information
alikic
authored
Apr 15, 2020
1 parent
0e550fc
commit 60484dd
Showing
20 changed files
with
405 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
Copyright SecureKey Technologies Inc. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package mocks | ||
|
||
import ( | ||
"path/filepath" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
"github.com/hyperledger/fabric-sdk-go/test/metadata" | ||
) | ||
|
||
func getConfigPath() string { | ||
return filepath.Join(metadata.GetProjectPath(), "pkg", "core", "config", "testdata") | ||
} | ||
|
||
func TestMockConfigBackend(t *testing.T) { | ||
|
||
configPath := filepath.Join(getConfigPath(), "config_test.yaml") | ||
mockBackend, err := BackendFromFile(configPath) | ||
if err != nil { | ||
t.Fatalf("Unexpected error reading config: %s", err) | ||
} | ||
|
||
v, ok := mockBackend.Get("client") | ||
assert.True(t, ok, "!ok") | ||
assert.NotNil(t, v, "client not found") | ||
assert.True(t, reflect.TypeOf(v) == reflect.TypeOf(map[string]interface{}{}), "wrong type") | ||
|
||
v, ok = mockBackend.Get("client.tlscerts.systemcertpool") | ||
assert.True(t, ok, "!ok") | ||
assert.True(t, reflect.TypeOf(v) == reflect.TypeOf(true), "wrong type") | ||
assert.False(t, v.(bool), "wrong value") | ||
|
||
mockBackend.Set("client.tlscerts.systemcertpool", true) | ||
v, ok = mockBackend.Get("client.tlscerts.systemcertpool") | ||
assert.True(t, ok, "!ok") | ||
assert.True(t, reflect.TypeOf(v) == reflect.TypeOf(true), "wrong type") | ||
assert.True(t, v.(bool), "wrong value") | ||
|
||
v, ok = mockBackend.Get("some.new.value") | ||
assert.False(t, ok, "should not be ok") | ||
mockBackend.Set("some.new.value", "Hello World") | ||
v, ok = mockBackend.Get("some.new.value") | ||
assert.True(t, ok, "!ok") | ||
assert.True(t, reflect.TypeOf(v) == reflect.TypeOf(""), "wrong type") | ||
assert.Equal(t, "Hello World", v) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.