github.com/leonlxy/hyperledger@v1.0.0-alpha.0.20170427033203-34922035d248/docs/source/Setup/ca-setup.rst (about)

     1  Fabric CA User's Guide
     2  ======================
     3  
     4  Fabric CA is a Certificate Authority for Hyperledger Fabric.
     5  
     6  | It provides features such as:
     7  | 1) registration of identities, or connects to LDAP as the user
     8    registry;
     9  | 2) issuance of Enrollment Certificates (ECerts);
    10  | 3) issuance of Transaction Certificates (TCerts), providing both
    11    anonymity and unlinkability when transacting on a Hyperledger Fabric
    12    blockchain;
    13  | 4) certificate renewal and revocation.
    14  
    15  Fabric CA consists of both a server and a client component as described
    16  later in this document.
    17  
    18  For developers interested in contributing to Fabric CA, see the `Fabric
    19  CA repository <https://github.com/hyperledger/fabric-ca>`__ for more
    20  information.
    21  
    22  
    23  .. _Back to Top:
    24  
    25  Table of Contents
    26  -----------------
    27  
    28  1. `Overview`_
    29  
    30  2. `Getting Started`_
    31  
    32     1. `Prerequisites`_
    33     2. `Install`_
    34     3. `Explore the Fabric CA CLI`_
    35  
    36  3. `File Formats`_
    37  
    38     1. `Fabric CA server's configuration file format`_
    39     2. `Fabric CA client's configuration file format`_
    40  
    41  4. `Configuration Settings Precedence`_
    42  
    43  5. `Fabric CA Server`_
    44  
    45     1. `Initializing the server`_
    46     2. `Starting the server`_
    47     3. `Configuring the database`_
    48     4. `Configuring LDAP`_
    49     5. `Setting up a cluster`_
    50  
    51  6. `Fabric CA Client`_
    52  
    53     1. `Enrolling the bootstrap user`_
    54     2. `Registering a new identity`_
    55     3. `Enrolling a peer identity`_
    56     4. `Reenrolling an identity`_
    57     5. `Revoking a certificate or identity`_
    58     6. `Enabling TLS`_
    59  
    60  7. `Appendix`_
    61  
    62  Overview
    63  --------
    64  
    65  The diagram below illustrates how the Fabric CA server fits into the
    66  overall Hyperledger Fabric architecture.
    67  
    68  .. image:: ../images/fabric-ca.png
    69  
    70  There are two ways of interacting with a Fabric CA server:
    71  via the Fabric CA client or through one of the Fabric SDKs.
    72  All communication to the Fabric CA server is via REST APIs.
    73  See `fabric-ca/swagger/swagger-fabric-ca.json` for the swagger documentation
    74  for these REST APIs.
    75  
    76  The Fabric CA client or SDK may connect to a server in a cluster of Fabric CA
    77  servers.   This is illustrated in the top right section of the diagram.
    78  The client routes to an HA Proxy endpoint which load balances traffic to one
    79  of the fabric-ca-server cluster members.
    80  All Fabric CA servers in a cluster share the same database for
    81  keeping track of users and certificates.  If LDAP is configured, the user
    82  information is kept in LDAP rather than the database.
    83  
    84  Getting Started
    85  ---------------
    86  
    87  Prerequisites
    88  ~~~~~~~~~~~~~~~
    89  
    90  -  Go 1.7+ installation or later
    91  -  **GOPATH** environment variable is set correctly
    92  - libtool and libtdhl-dev packages are installed
    93  
    94  The following installs the libtool dependencies.
    95  
    96  ::
    97  
    98     # sudo apt install libtool libltdl-dev
    99  
   100  For more information on libtool, see https://www.gnu.org/software/libtool.
   101  
   102  For more information on libtdhr-dev, see https://www.gnu.org/software/libtool/manual/html_node/Using-libltdl.html.
   103  
   104  Install
   105  ~~~~~~~
   106  
   107  The following installs both the `fabric-ca-server` and `fabric-ca-client` commands.
   108  
   109  ::
   110  
   111      # go get -u github.com/hyperledger/fabric-ca/cmd/...
   112  
   113  Start Server Natively
   114  ~~~~~~~~~~~~~~~~~~~~~
   115  
   116  The following starts the `fabric-ca-server` with default settings.
   117  
   118  ::
   119  
   120      # fabric-ca-server start -b admin:adminpw
   121  
   122  The `-b` option provides the enrollment ID and secret for a bootstrap
   123  administrator.  A default configuration file named `fabric-ca-server-config.yaml`
   124  is created in the local directory which can be customized.
   125  
   126  Start Server via Docker
   127  ~~~~~~~~~~~~~~~~~~~~~~~
   128  
   129  You can build and start the server via docker-compose as shown below.
   130  
   131  ::
   132  
   133      # cd $GOPATH/src/github.com/hyperledger/fabric-ca
   134      # make docker
   135      # cd docker/server
   136      # docker-compose up -d
   137  
   138  The hyperledger/fabric-ca docker image contains both the fabric-ca-server and
   139  the fabric-ca-client.
   140  
   141  Explore the Fabric CA CLI
   142  ~~~~~~~~~~~~~~~~~~~~~~~~~~~
   143  
   144  This section simply provides the usage messages for the Fabric CA server and client
   145  for convenience.  Additional usage information is provided in following sections.
   146  
   147  The following shows the Fabric CA server usage message.
   148  
   149  ::
   150  
   151      Hyperledger Fabric Certificate Authority Server
   152  
   153      Usage:
   154        fabric-ca-server [command]
   155  
   156      Available Commands:
   157        init        Initialize the fabric-ca server
   158        start       Start the fabric-ca server
   159  
   160      Flags:
   161            --address string                  Listening address of fabric-ca-server (default "0.0.0.0")
   162        -b, --boot string                     The user:pass for bootstrap admin which is required to build default config file
   163            --ca.certfile string              PEM-encoded CA certificate file (default "ca-cert.pem")
   164            --ca.keyfile string               PEM-encoded CA key file (default "ca-key.pem")
   165        -c, --config string                   Configuration file (default "fabric-ca-server-config.yaml")
   166            --csr.cn string                   The common name field of the certificate signing request to a parent fabric-ca-server
   167            --csr.serialnumber string         The serial number in a certificate signing request to a parent fabric-ca-server
   168            --db.datasource string            Data source which is database specific (default "fabric-ca-server.db")
   169            --db.tls.certfiles string         PEM-encoded comma separated list of trusted certificate files (e.g. root1.pem, root2.pem)
   170            --db.tls.client.certfile string   PEM-encoded certificate file when mutual authentication is enabled
   171            --db.tls.client.keyfile string    PEM-encoded key file when mutual authentication is enabled
   172            --db.tls.enabled                  Enable TLS for client connection
   173            --db.type string                  Type of database; one of: sqlite3, postgres, mysql (default "sqlite3")
   174        -d, --debug                           Enable debug level logging
   175            --ldap.enabled                    Enable the LDAP client for authentication and attributes
   176            --ldap.groupfilter string         The LDAP group filter for a single affiliation group (default "(memberUid=%s)")
   177            --ldap.url string                 LDAP client URL of form ldap://adminDN:adminPassword@host[:port]/base
   178            --ldap.userfilter string          The LDAP user filter to use when searching for users (default "(uid=%s)")
   179        -p, --port int                        Listening port of fabric-ca-server (default 7054)
   180            --registry.maxenrollments int     Maximum number of enrollments; valid if LDAP not enabled
   181            --tls.certfile string             PEM-encoded TLS certificate file for server's listening port (default "ca-cert.pem")
   182            --tls.enabled                     Enable TLS on the listening port
   183            --tls.keyfile string              PEM-encoded TLS key for server's listening port (default "ca-key.pem")
   184        -u, --url string                      URL of the parent fabric-ca-server
   185  
   186      Use "fabric-ca-server [command] --help" for more information about a command.
   187  
   188  The following shows the Fabric CA client usage message:
   189  
   190  ::
   191  
   192      # fabric-ca-client
   193      Hyperledger Fabric Certificate Authority Client
   194  
   195      Usage:
   196        fabric-ca-client [command]
   197  
   198      Available Commands:
   199        enroll      Enroll user
   200        getcacert   Get CA certificate chain
   201        reenroll    Reenroll user
   202        register    Register user
   203        revoke      Revoke user
   204  
   205      Flags:
   206        -c, --config string                Configuration file (default "$HOME/.fabric-ca-client/fabric-ca-client-config.yaml")
   207            --csr.cn string                The common name field of the certificate signing request to a parent fabric-ca-server
   208            --csr.serialnumber string      The serial number in a certificate signing request to a parent fabric-ca-server
   209        -d, --debug                        Enable debug level logging
   210            --enrollment.hosts string      Comma-separated host list
   211            --enrollment.label string      Label to use in HSM operations
   212            --enrollment.profile string    Name of the signing profile to use in issuing the certificate
   213            --id.affiliation string        The identity's affiliation
   214            --id.attr string               Attributes associated with this identity (e.g. hf.Revoker=true)
   215            --id.maxenrollments int        The maximum number of times the secret can be reused to enroll
   216            --id.name string               Unique name of the identity
   217            --id.secret string             The enrollment secret for the identity being registered
   218            --id.type string               Type of identity being registered (e.g. 'peer, app, user')
   219        -M, --mspdir string                Membership Service Provider directory (default "msp")
   220        -m, --myhost string                Hostname to include in the certificate signing request during enrollment (default "$HOSTNAME")
   221            --tls.certfiles string         PEM-encoded comma separated list of trusted certificate files (e.g. root1.pem, root2.pem)
   222            --tls.client.certfile string   PEM-encoded certificate file when mutual authentication is enabled
   223            --tls.client.keyfile string    PEM-encoded key file when mutual authentication is enabled
   224            --tls.enabled                  Enable TLS for client connection
   225        -u, --url string                   URL of fabric-ca-server (default "http://localhost:7054")
   226  
   227      Use "fabric-ca-client [command] --help" for more information about a command.
   228  
   229  
   230  `Back to Top`_
   231  
   232  File Formats
   233  ------------
   234  
   235  Fabric CA server's configuration file format
   236  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   237  
   238  A configuration file can be provided to the server using the ``-c`` or ``--config``
   239  option. If the ``--config`` option is used and the specified file doesn't exist,
   240  a default configuration file (like the one shown below) will be created in the
   241  specified location. However, if no config option was used, it will be created in
   242  the server's home directory (see `Fabric CA Server <#server>`__ section more info).
   243  
   244  ::
   245  
   246      # Server's listening port (default: 7054)
   247      port: 7054
   248  
   249      # Enables debug logging (default: false)
   250      debug: false
   251  
   252      #############################################################################
   253      #  TLS section for the server's listening port
   254      #############################################################################
   255      tls:
   256        # Enable TLS (default: false)
   257        enabled: false
   258        certfile: ca-cert.pem
   259        keyfile: ca-key.pem
   260  
   261      #############################################################################
   262      #  The CA section contains the key and certificate files used when
   263      #  issuing enrollment certificates (ECerts) and transaction
   264      #  certificates (TCerts).
   265      #############################################################################
   266      ca:
   267        # Certificate file (default: ca-cert.pem)
   268        certfile: ca-cert.pem
   269        # Key file (default: ca-key.pem)
   270        keyfile: ca-key.pem
   271  
   272      #############################################################################
   273      #  The registry section controls how the fabric-ca-server does two things:
   274      #  1) authenticates enrollment requests which contain a username and password
   275      #     (also known as an enrollment ID and secret).
   276      #  2) once authenticated, retrieves the identity's attribute names and
   277      #     values which the fabric-ca-server optionally puts into TCerts
   278      #     which it issues for transacting on the Hyperledger Fabric blockchain.
   279      #     These attributes are useful for making access control decisions in
   280      #     chaincode.
   281      #  There are two main configuration options:
   282      #  1) The fabric-ca-server is the registry
   283      #  2) An LDAP server is the registry, in which case the fabric-ca-server
   284      #     calls the LDAP server to perform these tasks.
   285      #############################################################################
   286      registry:
   287        # Maximum number of times a password/secret can be reused for enrollment
   288        # (default: 0, which means there is no limit)
   289        maxEnrollments: 0
   290  
   291        # Contains user information which is used when LDAP is disabled
   292        identities:
   293           - name: <<<ADMIN>>>
   294             pass: <<<ADMINPW>>>
   295             type: client
   296             affiliation: ""
   297             attrs:
   298                hf.Registrar.Roles: "client,user,peer,validator,auditor,ca"
   299                hf.Registrar.DelegateRoles: "client,user,validator,auditor"
   300                hf.Revoker: true
   301                hf.IntermediateCA: true
   302  
   303      #############################################################################
   304      #  Database section
   305      #  Supported types are: "sqlite3", "postgres", and "mysql".
   306      #  The datasource value depends on the type.
   307      #  If the type is "sqlite3", the datasource value is a file name to use
   308      #  as the database store.  Since "sqlite3" is an embedded database, it
   309      #  may not be used if you want to run the fabric-ca-server in a cluster.
   310      #  To run the fabric-ca-server in a cluster, you must choose "postgres"
   311      #  or "mysql".
   312      #############################################################################
   313      db:
   314        type: sqlite3
   315        datasource: fabric-ca-server.db
   316        tls:
   317            enabled: false
   318            certfiles: db-server-cert.pem
   319            client:
   320              certfile: db-client-cert.pem
   321              keyfile: db-client-key.pem
   322  
   323      #############################################################################
   324      #  LDAP section
   325      #  If LDAP is enabled, the fabric-ca-server calls LDAP to:
   326      #  1) authenticate enrollment ID and secret (i.e. username and password)
   327      #     for enrollment requests
   328      #  2) To retrieve identity attributes
   329      #############################################################################
   330      ldap:
   331         # Enables or disables the LDAP client (default: false)
   332         enabled: false
   333         # The URL of the LDAP server
   334         url: ldap://<adminDN>:<adminPassword>@<host>:<port>/<base>
   335         tls:
   336            certfiles: ldap-server-cert.pem
   337            client:
   338               certfile: ldap-client-cert.pem
   339               keyfile: ldap-client-key.pem
   340  
   341      #############################################################################
   342      #  Affiliation section
   343      #############################################################################
   344      affiliations:
   345         org1:
   346            - department1
   347            - department2
   348         org2:
   349            - department1
   350  
   351      #############################################################################
   352      #  Signing section
   353      #############################################################################
   354      signing:
   355          profiles:
   356            ca:
   357               usage:
   358                 - cert sign
   359               expiry: 8000h
   360               caconstraint:
   361                 isca: true
   362          default:
   363            usage:
   364              - cert sign
   365            expiry: 8000h
   366  
   367      ###########################################################################
   368      #  Certificate Signing Request section for generating the CA certificate
   369      ###########################################################################
   370      csr:
   371         cn: fabric-ca-server
   372         names:
   373            - C: US
   374              ST: North Carolina
   375              L:
   376              O: Hyperledger
   377              OU: Fabric
   378         hosts:
   379           - <<<MYHOST>>>
   380         ca:
   381            pathlen:
   382            pathlenzero:
   383            expiry:
   384  
   385      #############################################################################
   386      #  Crypto section configures the crypto primitives used for all
   387      #############################################################################
   388      crypto:
   389        software:
   390           hash_family: SHA2
   391           security_level: 256
   392           ephemeral: false
   393           key_store_dir: keys
   394  
   395  Fabric CA client's configuration file format
   396  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   397  
   398  A configuration file can be provided to the client using the ``-c`` or ``--config``
   399  option. If the config option is used and the specified file doesn't exist,
   400  a default configuration file (like the one shown below) will be created in the
   401  specified location. However, if no config option was used, it will be created in
   402  the client's home directory (see `Fabric CA Client <#client>`__ section more info).
   403  
   404  ::
   405  
   406      #############################################################################
   407      # Client Configuration
   408      #############################################################################
   409  
   410      # URL of the fabric-ca-server (default: http://localhost:7054)
   411      URL: http://localhost:7054
   412  
   413      # Membership Service Provider (MSP) directory
   414      # When the client is used to enroll a peer or an orderer, this field must be
   415      # set to the MSP directory of the peer/orderer
   416      MSPDir:
   417  
   418      #############################################################################
   419      #    TLS section for secure socket connection
   420      #############################################################################
   421      tls:
   422        # Enable TLS (default: false)
   423        enabled: false
   424        certfiles:   # Comma Separated (e.g. root.pem, root2.pem)
   425        client:
   426          certfile:
   427          keyfile:
   428  
   429      #############################################################################
   430      #  Certificate Signing Request section for generating the CSR for
   431      #  an enrollment certificate (ECert)
   432      #############################################################################
   433      csr:
   434        cn: <<<ENROLLMENT_ID>>>
   435        names:
   436          - C: US
   437            ST: North Carolina
   438            L:
   439            O: Hyperledger
   440            OU: Fabric
   441        hosts:
   442         - <<<MYHOST>>>
   443        ca:
   444          pathlen:
   445          pathlenzero:
   446          expiry:
   447  
   448      #############################################################################
   449      #  Registration section used to register a new user with fabric-ca server
   450      #############################################################################
   451      id:
   452        name:
   453        type:
   454        affiliation:
   455        attrs:
   456          - name:
   457            value:
   458  
   459      #############################################################################
   460      #  Enrollment section used to enroll a user with fabric-ca server
   461      #############################################################################
   462      enrollment:
   463        hosts:
   464        profile:
   465        label:
   466  
   467  `Back to Top`_
   468  
   469  Configuration Settings Precedence
   470  ---------------------------------
   471  
   472  The Fabric CA provides 3 ways to configure settings on the fabric-ca-server
   473  and fabric-ca-client. The precedence order is:
   474  
   475  1. CLI flags
   476  2. Environment variables
   477  3. Configuration file
   478  
   479  In the remainder of this document, we refer to making changes to
   480  configuration files. However, configuration file changes can be
   481  overridden through environment variables or CLI flags.
   482  
   483  For example, if we have the following in the client configuration file:
   484  
   485  ::
   486  
   487      tls:
   488        # Enable TLS (default: false)
   489        enabled: false
   490  
   491        # TLS for the client's listenting port (default: false)
   492        certfiles:   # Comma Separated (e.g. root.pem, root2.pem)
   493        client:
   494          certfile: cert.pem
   495          keyfile:
   496  
   497  The following environment variable may be used to override the ``cert.pem``
   498  setting in the configuration file:
   499  
   500  ``export FABRIC_CA_CLIENT_TLS_CLIENT_CERTFILE=cert2.pem``
   501  
   502  If we wanted to override both the environment variable and configuration
   503  file, we can use a command line flag.
   504  
   505  ``fabric-ca-client enroll --tls.client.certfile cert3.pem``
   506  
   507  The same approach applies to fabric-ca-server, except instead of using
   508  ``FABIRC_CA_CLIENT`` as the prefix to environment variables,
   509  ``FABRIC_CA_SERVER`` is used.
   510  
   511  .. _server:
   512  
   513  
   514  A word on file paths
   515  --------------------
   516  All the properties in the Fabric CA server and client configuration file,
   517  that specify file names support both relative and absolute paths.
   518  Relative paths are relative to the config directory, where the
   519  configuration file is located. For example, if the config directory is
   520  ``~/config`` and the tls section is as shown below, the Fabric CA server
   521  or client will look for the ``root.pem`` file in the ``~/config``
   522  directory, ``cert.pem`` file in the ``~/config/certs`` directory and the
   523  ``key.pem`` file in the ``/abs/path`` directory
   524  
   525  ::
   526  
   527      tls:
   528        enabled: true
   529        certfiles:   root.pem
   530        client:
   531          certfile: certs/cert.pem
   532          keyfile: /abs/path/key.pem
   533  
   534  
   535  
   536  Fabric CA Server
   537  ----------------
   538  
   539  This section describes the Fabric CA server.
   540  
   541  You may initialize the Fabric CA server before starting it if you prefer.
   542  This provides an opportunity for you to generate a default configuration
   543  file but to review and customize its settings before starting it.
   544  
   545  | The fabric-ca-server's home directory is determined as follows:
   546  | - if the ``FABRIC_CA_SERVER_HOME`` environment variable is set, use
   547    its value;
   548  | - otherwise, if ``FABRIC_CA_HOME`` environment variable is set, use
   549    its value;
   550  | - otherwise, if the ``CA_CFG_PATH`` environment variable is set, use
   551    its value;
   552  | - otherwise, use current working directory.
   553  
   554  For the remainder of this server section, we assume that you have set
   555  the ``FABRIC_CA_HOME`` environment variable to
   556  ``$HOME/fabric-ca/server``.
   557  
   558  The instructions below assume that the server configuration file exists
   559  in the server's home directory.
   560  
   561  .. _initialize:
   562  
   563  Initializing the server
   564  ~~~~~~~~~~~~~~~~~~~~~~~
   565  
   566  Initialize the Fabric CA server as follows:
   567  
   568  ::
   569  
   570      # fabric-ca-server init -b admin:adminpw
   571  
   572  The ``-b`` (bootstrap user) option is required for initialization. At
   573  least one bootstrap user is required to start the fabric-ca-server. The
   574  server configuration file contains a Certificate Signing Request (CSR)
   575  section that can be configured. The following is a sample CSR.
   576  
   577  If you are going to connect to the fabric-ca-server remotely over TLS,
   578  replace "localhost" in the CSR section below with the hostname where you
   579  will be running your fabric-ca-server.
   580  
   581  .. _csr-fields:
   582  
   583  ::
   584  
   585      cn: localhost
   586      key:
   587          algo: ecdsa
   588          size: 256
   589      names:
   590        - C: US
   591          ST: "North Carolina"
   592          L:
   593          O: Hyperledger
   594          OU: Fabric
   595  
   596  All of the fields above pertain to the X.509 signing key and certificate which
   597  is generated by the ``fabric-ca-server init``.  This corresponds to the
   598  ``ca.certfile`` and ``ca.keyfile`` files in the server's configuration file.
   599  The fields are as follows:
   600  
   601  -  **cn** is the Common Name
   602  -  **key** specifies the algorithm and key size as described below
   603  -  **O** is the organization name
   604  -  **OU** is the organizational unit
   605  -  **L** is the location or city
   606  -  **ST** is the state
   607  -  **C** is the country
   608  
   609  If custom values for the CSR are required, you may customize the configuration
   610  file, delete the files specified by the ``ca.certfile`` and ``ca-keyfile``
   611  configuration items, and then run the ``fabric-ca-server init -b admin:adminpw``
   612  command again.
   613  
   614  The ``fabric-ca-server init`` command generates a self-signed CA certificate
   615  unless the ``-u <parent-fabric-ca-server-URL>`` option is specified.
   616  If the ``-u`` is specified, the server's CA certificate is signed by the
   617  parent fabric-ca-server.  The ``fabric-ca-server init`` command also
   618  generates a default configuration file named **fabric-ca-server-config.yaml**
   619  in the server's home directory.
   620  
   621  Algorithms and key sizes
   622  
   623  The CSR can be customized to generate X.509 certificates and keys that
   624  support both RSA and Elliptic Curve (ECDSA). The following setting is an
   625  example of the implementation of Elliptic Curve Digital Signature
   626  Algorithm (ECDSA) with curve ``prime256v1`` and signature algorithm
   627  ``ecdsa-with-SHA256``:
   628  
   629  ::
   630  
   631      key:
   632         algo: ecdsa
   633         size: 256
   634  
   635  The choice of algorithm and key size are based on security needs.
   636  
   637  Elliptic Curve (ECDSA) offers the following key size options:
   638  
   639  +--------+--------------+-----------------------+
   640  | size   | ASN1 OID     | Signature Algorithm   |
   641  +========+==============+=======================+
   642  | 256    | prime256v1   | ecdsa-with-SHA256     |
   643  +--------+--------------+-----------------------+
   644  | 384    | secp384r1    | ecdsa-with-SHA384     |
   645  +--------+--------------+-----------------------+
   646  | 521    | secp521r1    | ecdsa-with-SHA512     |
   647  +--------+--------------+-----------------------+
   648  
   649  RSA offers the following key size options:
   650  
   651  +--------+------------------+---------------------------+
   652  | size   | Modulus (bits)   | Signature Algorithm       |
   653  +========+==================+===========================+
   654  | 2048   | 2048             | sha256WithRSAEncryption   |
   655  +--------+------------------+---------------------------+
   656  | 4096   | 4096             | sha512WithRSAEncryption   |
   657  +--------+------------------+---------------------------+
   658  
   659  Starting the server
   660  ~~~~~~~~~~~~~~~~~~~
   661  
   662  Start the Fabric CA server as follows:
   663  
   664  ::
   665  
   666      # fabric-ca-server start -b <admin>:<adminpw>
   667  
   668  If the server has not been previously initialized, it will initialize
   669  itself as it starts for the first time.  During this initialization, the
   670  server will generate the ca-cert.pem and ca-key.pem files if they don't
   671  yet exist and will also create a default configuration file if it does
   672  not exist.  See the `Initialize the Fabric CA server <#initialize>`__ section.
   673  
   674  Unless the fabric-ca-server is configured to use LDAP, it must be
   675  configured with at least one pre-registered bootstrap user to enable you
   676  to register and enroll other identities. The ``-b`` option specifies the
   677  name and password for a bootstrap user.
   678  
   679  A different configuration file may be specified with the ``-c`` option
   680  as shown below.
   681  
   682  ::
   683  
   684      # fabric-ca-server start -c <path-to-config-file> -b <admin>:<adminpw>
   685  
   686  To cause the fabric-ca-server to listen on ``https`` rather than
   687  ``http``, set ``tls.enabled`` to ``true``.
   688  
   689  To limit the number of times that the same secret (or password) can be
   690  used for enrollment, set the ``registry.maxEnrollments`` in the configuration
   691  file to the appropriate value. If you set the value to 1, the fabric-ca
   692  server allows passwords to only be used once for a particular enrollment
   693  ID. If you set the value to 0, the fabric-ca-server places no limit on
   694  the number of times that a secret can be reused for enrollment. The
   695  default value is 0.
   696  
   697  The fabric-ca-server should now be listening on port 7054.
   698  
   699  You may skip to the `Fabric CA Client <#fabric-ca-client>`__ section if
   700  you do not want to configure the fabric-ca-server to run in a cluster or
   701  to use LDAP.
   702  
   703  Configuring the database
   704  ~~~~~~~~~~~~~~~~~~~~~~~~
   705  
   706  This section describes how to configure the fabric-ca-server to connect
   707  to Postgres or MySQL databases. The default database is SQLite and the
   708  default database file is ``fabric-ca-server.db`` in the Fabric CA
   709  server's home directory.
   710  
   711  If you don't care about running the fabric-ca-server in a cluster, you
   712  may skip this section; otherwise, you must configure either Postgres or
   713  MySQL as described below.
   714  
   715  Postgres
   716  ^^^^^^^^^^
   717  
   718  The following sample may be added to the server's configuration file in
   719  order to connect to a Postgres database. Be sure to customize the
   720  various values appropriately.
   721  
   722  ::
   723  
   724      db:
   725        type: postgres
   726        datasource: host=localhost port=5432 user=Username password=Password dbname=fabric-ca-server sslmode=verify-full
   727  
   728  Specifying *sslmode* configures the type of SSL authentication. Valid
   729  values for sslmode are:
   730  
   731  |
   732  
   733  +----------------+----------------+
   734  | Mode           | Description    |
   735  +================+================+
   736  | disable        | No SSL         |
   737  +----------------+----------------+
   738  | require        | Always SSL     |
   739  |                | (skip          |
   740  |                | verification)  |
   741  +----------------+----------------+
   742  | verify-ca      | Always SSL     |
   743  |                | (verify that   |
   744  |                | the            |
   745  |                | certificate    |
   746  |                | presented by   |
   747  |                | the server was |
   748  |                | signed by a    |
   749  |                | trusted CA)    |
   750  +----------------+----------------+
   751  | verify-full    | Same as        |
   752  |                | verify-ca AND  |
   753  |                | verify that    |
   754  |                | the            |
   755  |                | certificate    |
   756  |                | presented by   |
   757  |                | the server was |
   758  |                | signed by a    |
   759  |                | trusted CA and |
   760  |                | the server     |
   761  |                | host name      |
   762  |                | matches the    |
   763  |                | one in the     |
   764  |                | certificate    |
   765  +----------------+----------------+
   766  
   767  |
   768  
   769  If you would like to use TLS, then the ``db.tls`` section in the fabric-ca-server
   770  configuration file must be specified. If SSL client authentication is enabled
   771  on the Postgres server, then the client certificate and key file must also be
   772  specified in the ``db.tls.client`` section. The following is an example
   773  of the ``db.tls`` section:
   774  
   775  ::
   776  
   777      db:
   778        ...
   779        tls:
   780            enabled: true
   781            certfiles: db-server-cert.pem
   782            client:
   783                  certfile: db-client-cert.pem
   784                  keyfile: db-client-key.pem
   785  
   786  | **certfiles** - Comma separated list of PEM-encoded trusted root certificate files.
   787  | **certfile** and **keyfile** - PEM-encoded certificate and key files that are used by the Fabric CA server to communicate securely with the Postgres server
   788  
   789  MySQL
   790  ^^^^^^^
   791  
   792  The following sample may be added to the fabric-ca-server config file in
   793  order to connect to a MySQL database. Be sure to customize the various
   794  values appropriately.
   795  
   796  ::
   797  
   798      db:
   799        type: mysql
   800        datasource: root:rootpw@tcp(localhost:3306)/fabric-ca?parseTime=true&tls=custom
   801  
   802  If connecting over TLS to the MySQL server, the ``db.tls.client``
   803  section is also required as described in the **Postgres** section above.
   804  
   805  Configuring LDAP
   806  ~~~~~~~~~~~~~~~~
   807  
   808  The fabric-ca-server can be configured to read from an LDAP server.
   809  
   810  In particular, the fabric-ca-server may connect to an LDAP server to do
   811  the following:
   812  
   813  -  authenticate a user prior to enrollment
   814  -  retrieve a user's attribute values which are used for authorization.
   815  
   816  Modify the LDAP section of the server's configuration file to configure the
   817  fabric-ca-server to connect to an LDAP server.
   818  
   819  ::
   820  
   821      ldap:
   822         # Enables or disables the LDAP client (default: false)
   823         enabled: false
   824         # The URL of the LDAP server
   825         url: <scheme>://<adminDN>:<adminPassword>@<host>:<port>/<base>
   826         userfilter: filter
   827  
   828  | where:
   829  | \* ``scheme`` is one of *ldap* or *ldaps*;
   830  | \* ``adminDN`` is the distinquished name of the admin user;
   831  | \* ``pass`` is the password of the admin user;
   832  | \* ``host`` is the hostname or IP address of the LDAP server;
   833  | \* ``port`` is the optional port number, where default 389 for *ldap*
   834    and 636 for *ldaps*;
   835  | \* ``base`` is the optional root of the LDAP tree to use for searches;
   836  | \* ``filter`` is a filter to use when searching to convert a login
   837    user name to a distinquished name. For example, a value of
   838    ``(uid=%s)`` searches for LDAP entries with the value of a ``uid``
   839    attribute whose value is the login user name. Similarly,
   840    ``(email=%s)`` may be used to login with an email address.
   841  
   842  The following is a sample configuration section for the default settings
   843  for the OpenLDAP server whose docker image is at
   844  ``https://github.com/osixia/docker-openldap``.
   845  
   846  ::
   847  
   848      ldap:
   849         enabled: true
   850         url: ldap://cn=admin,dc=example,dc=org:admin@localhost:10389/dc=example,dc=org
   851         userfilter: (uid=%s)
   852  
   853  See ``FABRIC_CA/scripts/run-ldap-tests`` for a script which starts an
   854  OpenLDAP docker image, configures it, runs the LDAP tests in
   855  ``FABRIC_CA/cli/server/ldap/ldap_test.go``, and stops the OpenLDAP
   856  server.
   857  
   858  When LDAP is configured, enrollment works as follows:
   859  
   860  
   861  -  The fabric-ca-client or client SDK sends an enrollment request with a
   862     basic authorization header.
   863  -  The fabric-ca-server receives the enrollment request, decodes the
   864     user name and password in the authorization header, looks up the DN (Distinquished
   865     Name) associated with the user name using the "userfilter" from the
   866     configuration file, and then attempts an LDAP bind with the user's
   867     password. If the LDAP bind is successful, the enrollment processing is
   868     authorized and can proceed.
   869  
   870  When LDAP is configured, attribute retrieval works as follows:
   871  
   872  
   873  -  A client SDK sends a request for a batch of tcerts **with one or more
   874     attributes** to the fabric-ca-server.
   875  -  The fabric-ca-server receives the tcert request and does as follows:
   876  
   877     -  extracts the enrollment ID from the token in the authorization
   878        header (after validating the token);
   879     -  does an LDAP search/query to the LDAP server, requesting all of
   880        the attribute names received in the tcert request;
   881     -  the attribute values are placed in the tcert as normal.
   882  
   883  Setting up a cluster
   884  ~~~~~~~~~~~~~~~~~~~~
   885  
   886  You may use any IP sprayer to load balance to a cluster of fabric-ca
   887  servers. This section provides an example of how to set up Haproxy to
   888  route to a fabric-ca-server cluster. Be sure to change hostname and port
   889  to reflect the settings of your fabric-ca servers.
   890  
   891  haproxy.conf
   892  
   893  ::
   894  
   895      global
   896            maxconn 4096
   897            daemon
   898  
   899      defaults
   900            mode http
   901            maxconn 2000
   902            timeout connect 5000
   903            timeout client 50000
   904            timeout server 50000
   905  
   906      listen http-in
   907            bind *:7054
   908            balance roundrobin
   909            server server1 hostname1:port
   910            server server2 hostname2:port
   911            server server3 hostname3:port
   912  
   913  
   914  Node: If using TLS, need to use ``mode tcp``.
   915  
   916  `Back to Top`_
   917  
   918  .. _client:
   919  
   920  Fabric CA Client
   921  ----------------
   922  
   923  This section describes how to use the fabric-ca-client command.
   924  
   925  | The fabric-ca-client's home directory is determined as follows:
   926  | - if the ``FABRIC_CA_CLIENT_HOME`` environment variable is set, use
   927    its value;
   928  | - otherwise, if the ``FABRIC_CA_HOME`` environment variable is set,
   929    use its value;
   930  | - otherwise, if the ``CA_CFG_PATH`` environment variable is set, use
   931    its value;
   932  | - otherwise, use ``$HOME/.fabric-ca-client``.
   933  
   934  
   935  The instructions below assume that the client configuration file exists
   936  in the client's home directory.
   937  
   938  Enrolling the bootstrap user
   939  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   940  
   941  First, if needed, customize the CSR (Certificate Signing Request) section
   942  in the client configuration file. Note that ``csr.cn`` field must be set
   943  to the ID of the bootstrap user. Default CSR values are shown below:
   944  
   945  ::
   946  
   947      csr:
   948        cn: <<enrollment ID>>
   949        key:
   950          algo: ecdsa
   951          size: 256
   952        names:
   953          - C: US
   954            ST: North Carolina
   955            L:
   956            O: Hyperledger Fabric
   957            OU: Fabric CA
   958        hosts:
   959         - <<hostname of the fabric-ca-client>>
   960        ca:
   961          pathlen:
   962          pathlenzero:
   963          expiry:
   964  
   965  See `CSR fields <#csr-fields>`__ for description of the fields.
   966  
   967  Then run ``fabric-ca-client enroll`` command to enroll the user. For example,
   968  following command enrolls an user whose ID is **admin** and password is **adminpw**
   969  by calling fabric-ca-server that is running locally at 7054 port.
   970  
   971  ::
   972  
   973      # export FABRIC_CA_CLIENT_HOME=$HOME/fabric-ca/clients/admin
   974      # fabric-ca-client enroll -u http://admin:adminpw@localhost:7054
   975  
   976  The enroll command stores an enrollment certificate (ECert), corresponding private key and CA
   977  certificate chain PEM files in the subdirectories of the fabric-ca-client's ``msp`` directory.
   978  You will see messages indicating where the PEM files are stored.
   979  
   980  Registering a new identity
   981  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   982  
   983  The user performing the register request must be currently enrolled, and
   984  must also have the proper authority to register the type of user being
   985  registered.
   986  
   987  In particular, two authorization checks are made by the fabric-ca-server
   988  during registration as follows:
   989  
   990   1. The invoker's identity must have the "hf.Registrar.Roles" attribute with a
   991      comma-separated list of values where one of the value equals the type of
   992      identity being registered; for example, if the invoker's identity has the
   993      "hf.Registrar.Roles" attribute with a value of "peer,app,user", the invoker
   994      can register identities of type peer, app, and user, but not orderer.
   995  
   996   2. The affiliation of the invoker's identity must be equal to or a prefix of
   997      the affiliation of the identity being registered.  For example, an invoker
   998      with an affiliation of "a.b" may register an identity with an affiliation
   999      of "a.b.c" but may not register an identity with an affiliation of "a.c".
  1000  
  1001  The following command uses the **admin** user's credentials to register a new
  1002  identity with an enrollment id of "admin2", a type of "user", an affiliation of
  1003  "org1.department1", and an attribute named "hf.Revoker" with a value of "true".
  1004  
  1005  ::
  1006  
  1007      # export FABRIC_CA_CLIENT_HOME=$HOME/fabric-ca/clients/admin
  1008      # fabric-ca-client register --id.name admin2 --id.type user --id.affiliation org1.department1 --id.attr hf.Revoker=true
  1009  
  1010  The password, also known as the enrollment secret, is printed.
  1011  This password is required to enroll the user.
  1012  This allows an administrator to register an identity and to then give the
  1013  enrollment ID and secret to someone else to enroll the identity.
  1014  
  1015  You may set default values for any of the fields used in the register command
  1016  by editing the client's configuration file.  For example, suppose the configuration
  1017  file contains the following:
  1018  
  1019  ::
  1020  
  1021      id:
  1022        name:
  1023        type: user
  1024        affiliation: org1.department1
  1025        attrs:
  1026          - name: hf.Revoker
  1027            value: true
  1028          - name: anotherAttrName
  1029            value: anotherAttrValue
  1030  
  1031  The following command would then register a new identity with an enrollment id of
  1032  "admin3" which it takes from the command line, and the remainder is taken from the
  1033  config file including a type of "user", an affiliation of "org1.department1", and two attributes:
  1034  "hf.Revoker" with a value of "true" and "anotherAttrName" with a value of "anotherAttrValue".
  1035  
  1036  ::
  1037  
  1038      # export FABRIC_CA_CLIENT_HOME=$HOME/fabric-ca/clients/admin
  1039      # fabric-ca-client register --id.name admin3
  1040  
  1041  To register a user with multiple attributes requires specifying all attribute names and values
  1042  in the configuration file as shown above.
  1043  
  1044  Next, let's register a peer identity which will be used to enroll the peer in the following section.
  1045  The following command registers the **peer1** identity.  Note that we choose to specify our own
  1046  password (or secret) rather than letting the server generate one for us.
  1047  
  1048  ::
  1049  
  1050      # export FABRIC_CA_CLIENT_HOME=$HOME/fabric-ca/clients/admin
  1051      # fabric-ca-client register --id.name peer1 --id.type peer --id.affiliation org1.department1 --id.secret peer1pw
  1052  
  1053  Enrolling a Peer Identity
  1054  ~~~~~~~~~~~~~~~~~~~~~~~~~
  1055  
  1056  Now that you have successfully registered a peer identity, you may now
  1057  enroll the peer given the enrollment ID and secret (i.e. the *password*
  1058  from the previous section).  This is similar to enrolling the bootstrap user
  1059  except that we also demonstrate how to use the "-M" option to populate the
  1060  Hyperledger Fabric MSP (Membership Service Provider) directory structure.
  1061  
  1062  The following command enrolls peer1.
  1063  Be sure to replace the value of the "-M" option with the path to your
  1064  peer's MSP directory which is the
  1065  'mspConfigPath' setting in the peer's core.yaml file.
  1066  You may also set the FABRIC_CA_CLIENT_HOME to the home directory of your peer.
  1067  
  1068  ::
  1069  
  1070      # export FABRIC_CA_CLIENT_HOME=$HOME/fabric-ca/clients/peer1
  1071      # fabric-ca-client enroll -u http://peer1:peer1pw@localhost:7054 -M $FABRIC_CA_CLIENT_HOME/msp
  1072  
  1073  Enrolling an orderer is the same, except the path to the MSP directory is
  1074  the 'LocalMSPDir' setting in your orderer's orderer.yaml file.
  1075  
  1076  Getting a CA certificate chain from another fabric-ca-server
  1077  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1078  
  1079  In general, the cacerts directory of the MSP directory must contain the certificate authority chains
  1080  of other certificate authorities, representing all of the roots of trust for the peer.
  1081  
  1082  The ``fabric-ca-client getcacerts`` command is used to retrieve these certificate chains from other
  1083  fabric-ca-server instances.
  1084  
  1085  For example, the following will start a second fabric-ca-server on localhost
  1086  listening on port 7055 with a name of "CA2".  This represents a completely separate
  1087  root of trust and would be managed by a different member on the blockchain.
  1088  
  1089  ::
  1090  
  1091      # export FABRIC_CA_SERVER_HOME=$HOME/ca2
  1092      # fabric-ca-server start -b admin:ca2pw -p 7055 -n CA2
  1093  
  1094  The following command will install CA2's certificate chain into peer1's MSP directory.
  1095  
  1096  ::
  1097  
  1098      # export FABRIC_CA_CLIENT_HOME=$HOME/fabric-ca/clients/peer1
  1099      # fabric-ca-client getcacert -u http://localhost:7055 -M $FABRIC_CA_CLIENT_HOME/msp
  1100  
  1101  Reenrolling an Identity
  1102  ~~~~~~~~~~~~~~~~~~~~~~~
  1103  
  1104  Suppose your enrollment certificate is about to expire or has been compromised.
  1105  You can issue the reenroll command to renew your enrollment certificate as follows.
  1106  
  1107  ::
  1108  
  1109      # export FABRIC_CA_CLIENT_HOME=$HOME/fabric-ca/clients/peer1
  1110      # fabric-ca-client reenroll
  1111  
  1112  Revoking a certificate or identity
  1113  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1114  An identity or a certificate can be revoked. Revoking an identity will revoke all
  1115  the certificates owned by the identity and will also prevent the identity from getting
  1116  any new certificates. Revoking a certificate will invalidate a single certificate.
  1117  
  1118  In order to revoke a certificate or an identity, the calling identity must have
  1119  the ``hf.Revoker`` attribute. The revoking identity can only revoke a certificate
  1120  or an identity that has an affiliation that is equal to or prefixed by the revoking
  1121  identity's affiliation.
  1122  
  1123  For example, a revoker with affiliation **orgs.org1** can revoke an identity
  1124  affiliated with **orgs.org1** or **orgs.org1.department1** but can't revoke an
  1125  identity affiliated with **orgs.org2**.
  1126  
  1127  The following command disables an identity and revokes all of the certificates
  1128  associated with the identity. All future requests received by the fabric-ca-server
  1129  from this identity will be rejected.
  1130  
  1131  ::
  1132  
  1133      fabric-ca-client revoke -e <enrollment_id> -r <reason>
  1134  
  1135  The following are the supported reasons that can be specified using ``-r`` flag:
  1136  
  1137  1. unspecified
  1138  2. keycompromise
  1139  3. cacompromise
  1140  4. affiliationchange
  1141  5. superseded
  1142  6. cessationofoperation
  1143  7. certificatehold
  1144  8. removefromcrl
  1145  9. privilegewithdrawn
  1146  10. aacompromise
  1147  
  1148  For example, the bootstrap admin who is associated with root of the affiliation tree
  1149  can revoke **peer1**'s identity as follows:
  1150  
  1151  ::
  1152  
  1153      # export FABRIC_CA_CLIENT_HOME=$HOME/fabric-ca/clients/admin
  1154      # fabric-ca-client revoke -e peer1
  1155  
  1156  An enrollment certificate that belongs to an identity can be revoked by
  1157  specifying its AKI (Authority Key Identifier) and serial number as follows:
  1158  
  1159  ::
  1160  
  1161      fabric-ca-client revoke -a xxx -s yyy -r <reason>
  1162  
  1163  For example, you can get the AKI and the serial number of a certificate using the openssl command
  1164  and pass them to the ``revoke`` command to revoke the said certificate as follows:
  1165  
  1166  ::
  1167  
  1168     serial=$(openssl x509 -in userecert.pem -serial -noout | cut -d "=" -f 2)
  1169     aki=$(openssl x509 -in userecert.pem -text | awk '/keyid/ {gsub(/ *keyid:|:/,"",$1);print tolower($0)}')
  1170     fabric-ca-client revoke -s $serial -a $aki -r affiliationchange
  1171  
  1172  Enabling TLS
  1173  ~~~~~~~~~~~~
  1174  
  1175  This section describes in more detail how to configure TLS for a
  1176  fabric-ca-client.
  1177  
  1178  The following sections may be configured in the ``fabric-ca-client-config.yaml``.
  1179  
  1180  ::
  1181  
  1182      tls:
  1183        # Enable TLS (default: false)
  1184        enabled: true
  1185        certfiles: root.pem   # Comma Separated (e.g. root.pem,root2.pem)
  1186        client:
  1187          certfile: tls_client-cert.pem
  1188          keyfile: tls_client-key.pem
  1189  
  1190  The **certfiles** option is the set of root certificates trusted by the
  1191  client. This will typically just be the root fabric-ca-server's
  1192  certificate found in the server's home directory in the **ca-cert.pem**
  1193  file.
  1194  
  1195  The **client** option is required only if mutual TLS is configured on
  1196  the server.
  1197  
  1198  `Back to Top`_
  1199  
  1200  Appendix
  1201  --------
  1202  
  1203  Postgres SSL Configuration
  1204  ~~~~~~~~~~~~~~~~~~~~~~~~~~
  1205  
  1206  **Basic instructions for configuring SSL on the Postgres server:**
  1207  
  1208  1. In postgresql.conf, uncomment SSL and set to "on" (SSL=on)
  1209  
  1210  2. Place certificate and key files in the Postgres data directory.
  1211  
  1212  Instructions for generating self-signed certificates for:
  1213  https://www.postgresql.org/docs/9.5/static/ssl-tcp.html
  1214  
  1215  Note: Self-signed certificates are for testing purposes and should not
  1216  be used in a production environment
  1217  
  1218  **Postgres Server - Require Client Certificates**
  1219  
  1220  1. Place certificates of the certificate authorities (CAs) you trust in the file root.crt in the Postgres data directory
  1221  
  1222  2. In postgresql.conf, set "ssl\_ca\_file" to point to the root cert of client (CA cert)
  1223  
  1224  3. Set the clientcert parameter to 1 on the appropriate hostssl line(s) in pg\_hba.conf.
  1225  
  1226  For more details on configuring SSL on the Postgres server, please refer
  1227  to the following Postgres documentation:
  1228  https://www.postgresql.org/docs/9.4/static/libpq-ssl.html
  1229  
  1230  MySQL SSL Configuration
  1231  ~~~~~~~~~~~~~~~~~~~~~~~
  1232  
  1233  On MySQL 5.7.X, certain modes affect whether the server permits '0000-00-00' as a valid date.
  1234  It might be necessary to relax the modes that MySQL server uses. We want to allow
  1235  the server to be able to accept zero date values.
  1236  
  1237  Please refer to the following MySQL documentation on different modes available
  1238  and select the appropriate settings for the specific version of MySQL that is
  1239  being used.
  1240  
  1241  https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html
  1242  
  1243  **Basic instructions for configuring SSL on MySQL server:**
  1244  
  1245  1. Open or create my.cnf file for the server. Add or un-comment the
  1246     lines below in the [mysqld] section. These should point to the key and
  1247     certificates for the server, and the root CA cert.
  1248  
  1249     Instructions on creating server and client side certficates:
  1250     http://dev.mysql.com/doc/refman/5.7/en/creating-ssl-files-using-openssl.html
  1251  
  1252     [mysqld] ssl-ca=ca-cert.pem ssl-cert=server-cert.pem ssl-key=server-key.pem
  1253  
  1254     Can run the following query to confirm SSL has been enabled.
  1255  
  1256     mysql> SHOW GLOBAL VARIABLES LIKE 'have\_%ssl';
  1257  
  1258     Should see:
  1259  
  1260     +----------------+----------------+
  1261     | Variable_name  | Value          |
  1262     +================+================+
  1263     | have_openssl   | YES            |
  1264     +----------------+----------------+
  1265     | have_ssl       | YES            |
  1266     +----------------+----------------+
  1267  
  1268  2. After the server-side SSL configuration is finished, the next step is
  1269     to create a user who has a privilege to access the MySQL server over
  1270     SSL. For that, log in to the MySQL server, and type:
  1271  
  1272     mysql> GRANT ALL PRIVILEGES ON *.* TO 'ssluser'@'%' IDENTIFIED BY
  1273     'password' REQUIRE SSL; mysql> FLUSH PRIVILEGES;
  1274  
  1275     If you want to give a specific ip address from which the user will
  1276     access the server change the '%' to the specific ip address.
  1277  
  1278  **MySQL Server - Require Client Certificates**
  1279  
  1280  Options for secure connections are similar to those used on the server side.
  1281  
  1282  -  ssl-ca identifies the Certificate Authority (CA) certificate. This
  1283     option, if used, must specify the same certificate used by the
  1284     server.
  1285  -  ssl-cert identifies MySQL server's certificate.
  1286  -  ssl-key identifies MySQL server's private key.
  1287  
  1288  Suppose that you want to connect using an account that has no special
  1289  encryption requirements or was created using a GRANT statement that
  1290  includes the REQUIRE SSL option. As a recommended set of
  1291  secure-connection options, start the MySQL server with at least
  1292  --ssl-cert and --ssl-key, and invoke the fabric-ca-server with
  1293  ``db.tls.certfiles`` option set in the Fabric CA server configuration file.
  1294  
  1295  To require that a client certificate also be specified, create the
  1296  account using the REQUIRE X509 option. Then the client must also specify
  1297  proper client key and certificate files; otherwise, the MySQL server
  1298  will reject the connection. To specify client key and certification files
  1299  for the Fabric CA server, set ``db.tls.certfiles``, ``db.tls.client.certfile``,
  1300  and the ``db.tls.client.keyfile`` configuration properties.
  1301  
  1302  `Back to Top`_