Summary
Fabric-X orderer local YAML config does not parse common uppercase PKCS11 BCCSP leaf keys such as Library, Pin, Label, Hash, and Security under General.BCCSP.PKCS11.
The same values are parsed successfully when those PKCS11 leaf keys are lowercase (library, pin, label, hash, security).
Affected versions
I reproduced this with:
hyperledger/fabric-x-orderer v1.0.0
- current
main at 3f71d848a2b93c4614de7dfc24a13af924f4fbe8
The vendored/current github.com/hyperledger/fabric-lib-go/bccsp/pkcs11.PKCS11Opts has JSON tags such as json:"library" but no YAML tags for the uppercase field names.
Reproducer
Given a local orderer config fragment like:
General:
BCCSP:
Default: PKCS11
PKCS11:
Library: /usr/local/lib/libkms_pkcs11.so
Pin: test-pin
Label: test-token
Hash: SHA2
Security: 256
loading it through config.LoadLocalConfigYaml leaves the nested PKCS11 values empty. For example, cfg.GeneralConfig.BCCSP.PKCS11.Library is "".
A minimal test showing the failure:
func TestPKCS11UppercaseYAML(t *testing.T) {
path := filepath.Join(t.TempDir(), "node_config.yaml")
content := []byte(`General:
BCCSP:
Default: PKCS11
PKCS11:
Library: /usr/local/lib/libkms_pkcs11.so
Pin: test-pin
Label: test-token
Hash: SHA2
Security: 256
`)
require.NoError(t, os.WriteFile(path, content, 0o600))
cfg, err := LoadLocalConfigYaml(path)
require.NoError(t, err)
require.Equal(t, "/usr/local/lib/libkms_pkcs11.so", cfg.GeneralConfig.BCCSP.PKCS11.Library)
}
The same test passes if the PKCS11 leaf keys are changed to lowercase:
General:
BCCSP:
Default: PKCS11
PKCS11:
library: /usr/local/lib/libkms_pkcs11.so
pin: test-pin
label: test-token
hash: SHA2
security: 256
Expected behavior
Fabric-X orderer should either:
- parse the common uppercase PKCS11 BCCSP fields (
Library, Pin, Label, Hash, Security), or
- document that Fabric-X orderer local YAML config requires lowercase PKCS11 leaf keys.
Actual behavior
LoadLocalConfigYaml uses yaml.Unmarshal directly:
err = yaml.Unmarshal(yamlFile, config)
The orderer config struct reaches factory.FactoryOpts, where PKCS11 is tagged for YAML, but the nested pkcs11.PKCS11Opts fields only have JSON tags. As a result, the uppercase YAML leaf keys are not populated.
Why this is surprising
Other Fabric-related config paths commonly accept uppercase PKCS11 fields. For example, fabric-lib-go factory tests use Viper/mapstructure with uppercase Library, Pin, and Label, and Fabric documentation also shows uppercase Library, Pin, and Label in HSM examples.
Fabric-X committer also reads service config through Viper/mapstructure, so the same uppercase PKCS11 fields work there. This creates an inconsistency between Fabric-X orderer local config and committer config.
Workaround
Downstream users can either:
- generate orderer PKCS11 leaf keys in lowercase, or
- patch
fabric-lib-go/bccsp/pkcs11.PKCS11Opts to add YAML tags such as yaml:"Library", yaml:"Pin", etc.
I verified locally that an orderer image built from fabric-x-orderer v1.0.0 with -tags pkcs11 and no local YAML-tag patch starts successfully when the generated orderer config uses lowercase PKCS11 leaf keys.
Summary
Fabric-X orderer local YAML config does not parse common uppercase PKCS11 BCCSP leaf keys such as
Library,Pin,Label,Hash, andSecurityunderGeneral.BCCSP.PKCS11.The same values are parsed successfully when those PKCS11 leaf keys are lowercase (
library,pin,label,hash,security).Affected versions
I reproduced this with:
hyperledger/fabric-x-ordererv1.0.0mainat3f71d848a2b93c4614de7dfc24a13af924f4fbe8The vendored/current
github.com/hyperledger/fabric-lib-go/bccsp/pkcs11.PKCS11Optshas JSON tags such asjson:"library"but no YAML tags for the uppercase field names.Reproducer
Given a local orderer config fragment like:
loading it through
config.LoadLocalConfigYamlleaves the nested PKCS11 values empty. For example,cfg.GeneralConfig.BCCSP.PKCS11.Libraryis"".A minimal test showing the failure:
The same test passes if the PKCS11 leaf keys are changed to lowercase:
Expected behavior
Fabric-X orderer should either:
Library,Pin,Label,Hash,Security), orActual behavior
LoadLocalConfigYamlusesyaml.Unmarshaldirectly:The orderer config struct reaches
factory.FactoryOpts, wherePKCS11is tagged for YAML, but the nestedpkcs11.PKCS11Optsfields only have JSON tags. As a result, the uppercase YAML leaf keys are not populated.Why this is surprising
Other Fabric-related config paths commonly accept uppercase PKCS11 fields. For example,
fabric-lib-gofactory tests use Viper/mapstructure with uppercaseLibrary,Pin, andLabel, and Fabric documentation also shows uppercaseLibrary,Pin, andLabelin HSM examples.Fabric-X committer also reads service config through Viper/mapstructure, so the same uppercase PKCS11 fields work there. This creates an inconsistency between Fabric-X orderer local config and committer config.
Workaround
Downstream users can either:
fabric-lib-go/bccsp/pkcs11.PKCS11Optsto add YAML tags such asyaml:"Library",yaml:"Pin", etc.I verified locally that an orderer image built from
fabric-x-orderer v1.0.0with-tags pkcs11and no local YAML-tag patch starts successfully when the generated orderer config uses lowercase PKCS11 leaf keys.