I want to overrride this section of the fabric-ca-server-config.yaml file by variables env:
csr:
cn: fabric-ca-server
names:
- C: US
ST: "North Carolina"
L:
O: Hyperledger
OU: Fabric
hosts:
- host1.example.com
- localhost
ca:
expiry: 131400h
pathlength: 1
For example I know that:
FABRIC_CA_SERVER_CSR_CN=fabric-ca-server
is equivalent to csr.cn
but
csr.names??
csr.host??
Could it be?:
FABRIC_CA_SERVER_CSR_NAMES=C:US,ST:"North Carolina",L:,O:Hyperledger,OU:Fabric
Regards
TL;DR: You can't override the CSR with env. variables, but you can customize the CSR in the config file.
Long answer:
There are two issues going on here:
1) The error you are getting states that the configuration is looking for a map (which is how it is formatted in the
fabric-ca-server-config.yaml
file).To create a map in a bash script variable, you need to declare the associative array:
2) However, environment variables can only be strings, so it does not appear possible to override the configuration CSR settings with environment variables. Something like
FABRIC_CA_SERVER_CSR_NAMES_OU
will not work becausenames:
is a map, so there could be multipleOU
entries.The docs state:
So, what I typically do is just create a minimal config file and copy it over to the CA container before running
init
. This seems to be enough (with the other sections taking default values):For some reason, if you include a custom
fabric-ca-server-config.yaml
file but exclude theregistry:
section, it does not register a bootstrap user, even if you use the command line-b
option. So, if you include thatregistry:
section, you therefore don't need the-b
option when you runinit
.You might also want to include the
ca:
section since you can force the created certificate to be saved to your custom name:Also, before running
init
I would clean up your home directory - sometimes the defaultca-cert.pem
(and key) already exist and are not replaced:Of course, after running
init
your key will be saved in themsp
directory tree under:I typically move it to the home directory and rename it for convenience: