github.com/hyperledger/fabric-ca@v2.0.0-alpha.0.20201120210307-7b4f34729db1+incompatible/docs/source/deployguide/ca-config.md (about)

     1  #  Checklist for a production CA server
     2  
     3  As you prepare to build a production Fabric CA server, you need to consider configuration of the following fields in the fabric-ca-server-config.yaml file.
     4  When you [initialize](../users-guide.html#initializing-the-server) the CA server, this file is generated for you so that you can customize it before actually starting the server.
     5  
     6  This checklist covers key configuration parameters for setting up a production network. Of course you can always refer to the [fabric-ca-server-config.yaml file](../serverconfig.html) for additional parameters or more information. The list of parameters in this topic includes:
     7  
     8  - [ca](#ca)
     9  - [tls](#tls)
    10  - [cafiles](#cafiles)
    11  - [intermediate ca](#intermediate-ca)
    12  - [port](#port)
    13  - [user registry](#user-registry)
    14  - [registry database](#registry-database)
    15  - [LDAP](#ldap)
    16  - [affiliations](#affiliations)
    17  - [csr](#csr)
    18  - [signing](#signing)
    19  - [bccsp](#bccsp)
    20  - [cors](#cors)
    21  - [cfg](#cfg)
    22  - [operations](#operations)
    23  - [metrics](#metrics)
    24  
    25  ## ca
    26  
    27  ```
    28  ca:
    29    # Name of this CA
    30    name:
    31    # Key file (is only used to import a private key into BCCSP)
    32    keyfile:
    33    # Certificate file (default: ca-cert.pem)
    34    certfile:
    35    # Chain file
    36    chainfile:
    37  ```
    38  
    39  Start by giving your CA a name. Often the name indicates the organization that this CA will serve. Or, if this is a TLS CA you might want to indicate that in the name. This `ca.name` is used when targeting this server for requests by the Fabric CA Client `--caname` parameter. If the crypto material for this CA is generated elsewhere, you can provide the name of the files along with the fully qualified path or relative path to where they reside. The `keyfile` parameter is the private key and `certfile` is the public key.
    40  
    41  The `chainfile` parameter applies only to intermediate CAs. When starting up an intermediate CA, the CA will create the chainfile at the location specified by this parameter. The file will contain the certificates of the trusted chain starting with the root cert plus any intermediate certificates.
    42  
    43  ## tls
    44  
    45  ```
    46  tls:
    47    # Enable TLS (default: false)
    48    enabled: true
    49    # TLS for the server's listening port
    50    certfile:
    51    keyfile:
    52    clientauth:
    53      type: noclientcert
    54      certfiles:
    55  ```
    56  
    57  Configure this section to enable TLS communications for the CA. After TLS is enabled, all nodes that transact with the CA will also need to enable TLS.
    58  
    59  - **`tls.enabled`**: For a secure production environment, TLS should be enabled for secure communications between nodes by setting `enabled: true` in the `tls` section of the config file. (Note that it is disabled by default which may be acceptable for a test network but for production it needs to be enabled.) This setting will configure `server-side TLS`, meaning that TLS will guarantee the identity of the _server_ to the client and provides a two-way encrypted channel between them.
    60  
    61  - **`tls.certfile`**: Every CA needs to register and enroll with its TLS CA before it can transact securely with other nodes in the organization. Therefore, before you can deploy an organization CA or an intermediate CA, you must first deploy the TLS CA and then register and enroll the organization CA bootstrap identity with the TLS CA to generate the organziation CA's TLS signed certificate. When you use the Fabric CA client to generate the certificates, the TLS signed cert is generated in the `signedcerts` folder of the specified msp directory of the `FABRIC_CA_CLIENT_HOME` folder. For example: `/msp/signcerts/cert.pem`. Then, in this `tls.certfile` field, provide the name and location of the generated TLS signed certificate. If this is the root TLS CA, this field can be blank.
    62  
    63  - **`tls.keyfile`**: Similar to the `tls.certfile`, provide the name and location of the generated TLS private key for this CA. For example: `/msp/keystore/87bf5eff47d33b13d7aee81032b0e8e1e0ffc7a6571400493a7c_sk`. If you are using an HSM or if this is a root TLS CA, this field will be blank.
    64  
    65  **Note:** Minimally in a production network, `server-side TLS` should be enabled.
    66  
    67  If server-side TLS is sufficient for your needs, you are done with this section. If you need to use mutual TLS in your network then you need to configure the following two additional fields. (Mutual TLS is disabled by default.)
    68  
    69  - **`tls.clientauth.type`**: If the server additionally needs to authenticate the identity of the _client_, then **mutual TLS** (mTLS) is required. When mTLS is configured, the client is required to send its certificate during a TLS handshake. To configure your CA for mTLS, set the `clientauth.type` to `RequireAndVerifyClientCert`.
    70  
    71  - **`tls.clientauth.certfiles`**: For mTLS only, provide the PEM-encoded list of root certificate authorities that the server uses when verifying client certificates. Specify the certificates in a dashed yaml list.
    72  
    73  ## cafiles
    74  
    75  ```
    76  cafiles:
    77  ```
    78  
    79  As mentioned in the topic on [Planning for a CA](ca-deploy-topology.html), the `cafiles` parameter can be used to configure a dual-headed CA -- a single CA that under the covers includes both an organization CA and a TLS CA. This usage pattern can be for convenience, allowing each CA to maintain its own configuration but still share the same back-end user database. In the `cafiles` parameter, enter the path to the `fabric-ca-server-config.yaml` of the second CA server, for example the TLS CA. The configuration of the secondary CA can contain all of the same elements as are found in the primary CA server config file except `port` and `tls` sections.
    80  
    81  If this is not a desired configuration for your CA, you can leave the value of this parameter blank.
    82  
    83  ## intermediate CA
    84  ```
    85  intermediate:
    86    parentserver:
    87      url:
    88      caname:
    89  
    90    enrollment:
    91      hosts:
    92      profile:
    93      label:
    94  
    95    tls:
    96      certfiles:
    97      client:
    98        certfile:
    99        keyfile:
   100  ```
   101  
   102  Intermediate CAs are not required, but to reduce the risk of your organization (root) CA becoming compromised, you may want to include one or more intermediate CAs in your network.
   103  
   104  **Important:** Before setting up an intermediate CA, you need to verify the value of the `csr.ca.pathlength` parameter in the parent CA. When set to `0`, the organization CA can issue intermediate CA certificates, but these intermediate CAs may not in turn enroll other intermediate CAs. If you want your intermediate CA to be able to enroll other intermediate CAs, the root ca `csr.ca.pathlength` needs to be set to `1`.  And if you want those intermediate CAs to enroll other intermediate CAs, the root ca `csr.ca.pathlength` would need to be set to `2`.
   105  
   106  - **`parentserver.url`**: Specify the parent server url in the format `https://<PARENT-CA-ENROLL-ID>:<PARENT-CA-SECRET>@<PARENT-CA-URL>:<PARENT-CA-PORT>`.
   107  - **`parentserver.caname`**: Enter `ca.name` of the parent CA server.
   108  - **`enrollment.profile:`**: Enter the value of the `signing.profile` for the parent CA. Normally this would be `ca`.
   109  - **`tls.certfiles`**: Enter the location and name of the TLS CA signing cert, `ca-cert.pem` file. For example, `tls/ca-cert.pem`. This location is relative to where the server configuration .yaml file exists.
   110  
   111  In addition to editing this `intermediate` section, you also need to edit the following sections of the configuration .yaml file for this intermediate CA:
   112  - `csr` - Ensure that the `csr.cn` field is blank.
   113  - `port` - Be sure to set a unique port for the intermediate CA.
   114  - `signing` - Verify that `isca` set to `true`, and `maxpathlen` is set to greater than `0` in the root CA only if the intermediate CA will serve as a parent CA to other intermediate CAs, otherwise it should be set to `0`. See the [signing](#signing) parameter.
   115  
   116  ## port
   117  ```
   118  port:
   119  ```
   120  
   121  Each CA must be running on its own unique port and obviously must not conflict with any other service running on that port. You need to decide what ports you want to use for your CAs ahead of time and configure that port in the .yaml file.
   122  
   123  ## user registry
   124  ```
   125  registry:
   126    # Maximum number of times a password/secret can be reused for enrollment
   127    # (default: -1, which means there is no limit)
   128    maxenrollments: -1
   129  
   130    # Contains identity information which is used when LDAP is disabled
   131    identities:
   132       - name: <<<adminUserName>>>
   133         pass: <<<adminPassword>>>
   134         type: client
   135         affiliation: ""
   136         attrs:
   137            hf.Registrar.Roles: "*"
   138            hf.Registrar.DelegateRoles: "*"
   139            hf.Revoker: true
   140            hf.IntermediateCA: true
   141            hf.GenCRL: true
   142            hf.Registrar.Attributes: "*"
   143            hf.AffiliationMgr: true
   144  ```
   145  If you are not using an LDAP user registry, then this section along with the associated registry database `db:` section are required. This section can be used to register a list of users with the CA when the server is started. Note that it simply registers the users and does not generate enrollment certificates for them. You use the Fabric CA client to generate the associated enrollment certificates.
   146  
   147  * `maxenrollments`: Used to restrict the number of times certificates can be generated for a user using the enroll ID and secret. The [reenroll](../users-guide.html#reenrolling-an-identity) command can be used to get certificates without any limitation.
   148  * `identities`: This section defines the list of users and their associated attributes to be registered when the CA is started. After you run the `fabric-ca-server init` command, the `<<<adminUserName>>>` and `<<<adminPassword>>>` here are replaced with the CA server bootstrap identity user and password specified with the `-b` option on the command.
   149  * `identities.type`: For Fabric, the list of valid types is `client`, `peer`, `admin`, `orderer`, and `member`.
   150  * `affiliation`: Select the affiliation to be associated with the user specified by the associated `name:` parameter. The list of possible affiliations is defined in the `affiliations:` section.
   151  * `attrs`: The list of roles included above would be for "admin" users, meaning they can register and enroll other users. If you are registering a non-admin user, you would not give them these permissions. The `hf` attributes associated with an identity affect that identity's ability to register other users. You should review the topic on [Registering a new identity](../users-guide.html#registering-a-new-identity) to understand the patterns that are required.
   152  
   153  When the user is subsequently "enrolled", the `type`, `affiliation`, and `attrs` are visible inside the user's signing certificate and are used by policies to enforce authorization. Recall that `enrollment` is a process whereby the Fabric CA issues a certificate key-pair, comprised of a signed cert and a private key that forms the identity. The private and public keys are first generated locally by the Fabric CA client, and the public key is then sent to the CA which returns an encoded certificate, the signing certificate.
   154  
   155  After a user has been registered, you can use the [`Identity`](../clientcli.html#identity-command) command to modify the properties of the user.
   156  
   157  ## registry database
   158  ```
   159  db:
   160    type: sqlite3
   161    datasource: fabric-ca-server.db
   162    tls:
   163        enabled: false
   164        certfiles:
   165        client:
   166          certfile:
   167          keyfile:
   168  ```
   169  
   170  The Fabric CA stores user identities, affiliations, credentials, and public certificates in a database. Use this section to specify the type of database to be used to store the CA data. Fabric supports three database **types**:
   171  
   172  - `sqlite` (SQLite Version 3)
   173  - `postgres` (PostgresSQL)
   174  - `mysql` (MySQL)
   175  
   176  If you are running the database in a cluster, you must choose `postgres` or `mysql` as the database type.
   177  
   178  If LDAP is being used as the user registry (designated by `ldap.enabled:true`), then this section is ignored.
   179  
   180  ## LDAP
   181  ```
   182  ldap:
   183     # Enables or disables the LDAP client (default: false)
   184     # If this is set to true, the "registry" section is ignored.
   185     enabled: false
   186     # The URL of the LDAP server
   187     url: ldap://<adminDN>:<adminPassword>@<host>:<port>/<base>
   188     # TLS configuration for the client connection to the LDAP server
   189     tls:
   190        certfiles:
   191        client:
   192           certfile:
   193           keyfile:
   194     # Attribute related configuration for mapping from LDAP entries to Fabric CA attributes
   195     attribute:
   196        # 'names' is an array of strings containing the LDAP attribute names which are
   197        # requested from the LDAP server for an LDAP identity's entry
   198        names: ['uid','member']
   199        # The 'converters' section is used to convert an LDAP entry to the value of
   200        # a fabric CA attribute.
   201        # For example, the following converts an LDAP 'uid' attribute
   202        # whose value begins with 'revoker' to a fabric CA attribute
   203        # named "hf.Revoker" with a value of "true" (because the boolean expression
   204        # evaluates to true).
   205        #    converters:
   206        #       - name: hf.Revoker
   207        #         value: attr("uid") =~ "revoker*"
   208        converters:
   209           - name:
   210             value:
   211        # The 'maps' section contains named maps which may be referenced by the 'map'
   212        # function in the 'converters' section to map LDAP responses to arbitrary values.
   213        # For example, assume a user has an LDAP attribute named 'member' which has multiple
   214        # values which are each a distinguished name (i.e. a DN). For simplicity, assume the
   215        # values of the 'member' attribute are 'dn1', 'dn2', and 'dn3'.
   216        # Further assume the following configuration.
   217        #    converters:
   218        #       - name: hf.Registrar.Roles
   219        #         value: map(attr("member"),"groups")
   220        #    maps:
   221        #       groups:
   222        #          - name: dn1
   223        #            value: peer
   224        #          - name: dn2
   225        #            value: client
   226        # The value of the user's 'hf.Registrar.Roles' attribute is then computed to be
   227        # "peer,client,dn3".  This is because the value of 'attr("member")' is
   228        # "dn1,dn2,dn3", and the call to 'map' with a 2nd argument of
   229        # "group" replaces "dn1" with "peer" and "dn2" with "client".
   230        maps:
   231           groups:
   232              - name:
   233                value:
   234  ```   
   235  
   236  If an LDAP registry is configured, all settings in the [registry](#user-registry) section are ignored.
   237  
   238  ## affiliations
   239  ```
   240  affiliations:
   241     org1:
   242        - department1
   243        - department2
   244     org2:
   245        - department1
   246  ```      
   247  
   248  Affiliations are useful to designate sub-departments for organizations. They can then be referenced from a policy definition, for example when you might want to have transactions endorsed by a peer who is not simply a member of ORG1, but is a member of ORG1.MANUFACTURING. Note that the affiliation of the registrar must be equal to or a prefix of the affiliation of the identity being registered. If you are considering using affiliations you should review the topic on [Registering a new identity](../users-guide.html#registering-a-new-identity) for requirements. To learn more about how affiliations are used in an MSP, see the MSP Key concept topic on [Organizational Units (OUs) and MSPs](https://hyperledger-fabric.readthedocs.io/en/release-2.1/membership/membership.html#organizational-units-ous-and-msps).
   249  
   250  The default affiliations listed above are added to the Fabric CA database the first time the server is started. If you prefer not to have these affiliations on your server, you need to edit this config file and remove or replace them _before_ you start the server for the first time. Otherwise, you must use the Fabric CA client [Affiliation command](../clientcli.html#affiliation-command) to modify the list of affiliations.  By default, affiliations cannot be removed from the configuration, rather that feature has to be explicitly enabled. See the [cfg](#cfg) section for instructions on configuring the ability to allow removal of affiliations.
   251  
   252  ## csr (certificate signing request)
   253  
   254  ```
   255  csr:
   256     cn: <<<COMMONNAME>>>
   257     keyrequest:
   258       algo: ecdsa
   259       size: 256
   260     names:
   261        - C: US
   262          ST: "North Carolina"
   263          L:
   264          O: Hyperledger
   265          OU: Fabric
   266     hosts:
   267       - <<<MYHOST>>>
   268       - localhost
   269     ca:
   270        expiry: 131400h
   271        pathlength: <<<PATHLENGTH>>>
   272  ```
   273  The CSR section controls the creation of the root CA certificate. Therefore, if you want to customize any values, it is recommended to configure this section before you start your server for the first time. The values you specify here will be included in the signing certificates that are generated. If you customize values for the CSR after you start the server, you need to delete the `ca.cert` file and `ca.key` files and then run the `fabric-ca-server start` command again.
   274  
   275  - **csr.cn**: This field must be set to the ID of the CA bootstrap identity and can be left blank. It defaults to the CA server bootstrap identity.
   276  - **csr.keyrequest**: Use these values ff you want to customize the crypto [algorithm and key sizes](../users-guide.html#initializing-the-server).
   277  - **csr.names**: Specify the values you want to use for the certificate Issuer, visible in the signing certificate.
   278  - **csr.hosts**: Provide the host names that the server will be running on.
   279  - **csr.expiry**: Specify when this CA's root certificate expires. The default value `131400h` is 15 years.
   280  - **csr.pathlength**: If you will have an intermediate CA, set this value to `1` in the root CA. If this is an intermediate CA the value would be `0` unless it will serve as a parent CA for another intermediate CA.
   281  
   282  ## signing
   283  
   284  ```
   285  signing:
   286      default:
   287        usage:
   288          - digital signature
   289        expiry: 8760h
   290      profiles:
   291        ca:
   292           usage:
   293             - cert sign
   294             - crl sign
   295           expiry: 43800h
   296           caconstraint:
   297             isca: true
   298             maxpathlen: 0
   299             maxpathlenzero: true
   300        tls:
   301           usage:
   302              - signing
   303              - key encipherment
   304              - server auth
   305              - client auth
   306              - key agreement
   307           expiry: 8760h
   308  ```
   309  
   310  The defaults in this section are normally sufficient for a production server. However, you might want to modify the default expiration of the generated organization CA and TLS certificates. Note that this is different than the `expiry` specified in the `csr` section for the CA root certificate.  
   311  
   312  If this is a TLS CA, it is recommended that you remove the `ca` section from `profiles:` since a TLS CA should only be issuing TLS certificates.
   313  
   314  If you plan to have more than one level of intermediate CAs, then you must set `maxpathlen` to greater than `0` in the configuration .yaml file for the root CA. This field represents the maximum number of non-self-issued intermediate certificates that can follow this certificate in a certificate chain. For example, if you plan to have intermediate CAs under this root CA, the `maxpathlen` can be set to `0`. But if you want your intermediate CA to serve as a parent CA to another intermediate CA, then `maxpathlen` should be set to `1`.
   315  
   316  To enforce a `maxpathlen` of `0`, you need to also set `maxpathlenzero` to true. If `maxpathlen` is greater than `0`, `maxpathlenzero` should be set to `false`.
   317  
   318  ## bccsp
   319  
   320  ```
   321  bccsp:
   322      default: SW
   323      sw:
   324          hash: SHA2
   325          security: 256
   326          filekeystore:
   327              # The directory used for the software file-based keystore
   328              keystore: msp/keystore
   329  ```
   330  
   331  The information in this section controls where the private key for the CA is stored. The configuration above causes the private key to be stored on the file system of the CA server in the `msp/keystore` folder. If you plan to use a Hardware Security Module (HSM) the configuration is different. When you [configure HSM for a CA](https://hyperledger-fabric.readthedocs.io/en/release-2.1/hsm.html#using-an-hsm-with-a-fabric-ca), the CA private key is generated by and stored in the HSM instead of the `msp/keystore` folder. An example of the HSM configuration for softHSM would be similar to:
   332  
   333  ```
   334  bccsp:
   335    default: PKCS11
   336    pkcs11:
   337      Library: /etc/hyperledger/fabric/libsofthsm2.so
   338      Pin: 71811222
   339      Label: fabric
   340      hash: SHA2
   341      security: 256
   342      Immutable: false
   343  ```
   344  
   345  ## cors
   346  ```
   347  cors:
   348      enabled: false
   349      origins:
   350        - "*"
   351  ```
   352  
   353  Cross-Origin Resource Sharing (CORS) can be configured to use additional HTTP headers to tell browsers to give a web application running at one origin access to selected resources from a different origin. The `origins` parameter contains a list of domains that are allowed to access the resources.
   354  
   355  ## cfg
   356  ```
   357  cfg:
   358    affiliations:
   359      allowremove: false
   360    identities:
   361      allowremove: false  
   362  ```
   363  
   364  These two parameters are not listed in the sample configuration file, but are important to understand. With the default configuration set to false, you will be unable to remove affiliations or identities without a server restart. If you anticipate the need to remove affiliations or identities from your production environment without a server restart, both of these fields should be set to `true` before starting your server. Note that after the server is started, affiliations and identities can only be modified by using the Fabric CA client CLI commands.  
   365  
   366  ## operations
   367  
   368  ```
   369  operations:
   370      # host and port for the operations server
   371      listenAddress: 127.0.0.1:9443
   372  
   373      # TLS configuration for the operations endpoint
   374      tls:
   375          # TLS enabled
   376          enabled: false
   377  
   378          # path to PEM encoded server certificate for the operations server
   379          cert:
   380              file:
   381  
   382          # path to PEM encoded server key for the operations server
   383          key:
   384              file:
   385  
   386          # require client certificate authentication to access all resources
   387          clientAuthRequired: false
   388  
   389          # paths to PEM encoded ca certificates to trust for client authentication
   390          clientRootCAs:
   391              files: []
   392  ```
   393  
   394  The operations service can be used for health monitoring of the CA and relies on mutual TLS for communication with the node.
   395  Therefore, you need to set `operations.tls.clientAuthRequired` to `true`. When this is set to `true`, clients attempting to ascertain the health of the node are  required to provide a valid certificate for authentication. If the client does not provide a certificate or the service cannot verify the client’s certificate, the request is rejected. This means that the clients will need to register with the TLS CA and provide their TLS signing certificate on the requests.
   396  
   397  In the case where two CAs are running on the same machine, you need to modify the `listenAddress:` for the second CA to use a different port. Otherwise, when you start the second CA, it will fail to start, reporting that `the bind address is already in use`.
   398  
   399  ## metrics
   400  
   401  ```
   402  metrics:
   403      # statsd, prometheus, or disabled
   404      provider: disabled
   405  
   406      # statsd configuration
   407      statsd:
   408          # network type: tcp or udp
   409          network: udp
   410  
   411          # statsd server address
   412          address: 127.0.0.1:8125
   413  
   414          # the interval at which locally cached counters and gauges are pushsed
   415          # to statsd; timings are pushed immediately
   416          writeInterval: 10s
   417  
   418          # prefix is prepended to all emitted statsd merics
   419          prefix: server
   420  ```
   421  
   422  If you want to monitor the metrics for the CA, choose your metrics provider:
   423  
   424  - **provider**: `Statsd` is a push model, `Prometheus` is a pull model. Because Prometheus is a pull model there is not any configuration required from the Fabric CA server side. Rather, Prometheus sends requests to the operations URL to poll for metrics. [Available metrics](../metrics_reference.html).
   425  
   426  ## Next steps
   427  
   428  After deciding on your CA configuration, you are ready to deploy your CAs. Follow instructions in the next CA Deployment steps topic to start your CA.
   429  
   430  
   431  <!--- Licensed under Creative Commons Attribution 4.0 International License
   432  https://creativecommons.org/licenses/by/4.0/ -->