Skip to content
Go to file

Latest commit

Move to latest versions of dependencies where possible.

Signed-off-by: Gari Singh <>

Git stats


Failed to load latest commit information.
Latest commit message
Commit time
Nov 19, 2020
Nov 19, 2020
Dec 27, 2019
May 21, 2020

Fabric CA Developer's Guide

This is the Developer's Guide for Fabric CA, which is a Certificate Authority for Hyperledger Fabric.

See User's Guide for Fabric CA for information on how to use Fabric CA.


  • Go 1.13+ installation or later
  • GOPATH environment variable is set correctly
  • docker version 17.03 or later
  • docker-compose version 1.11 or later
  • A Linux Foundation ID (see create a Linux Foundation ID)

Contribution guidelines

You are welcome to contribute to Fabric CA!

The following are guidelines to follow when contributing:

  1. See the general information about contributing to fabric.

  2. To run the unit tests manually:

    # cd $GOPATH/src/
    # make unit-tests

    The test coverage for each package must be 75% or greater. If this fails due to insufficient test coverage, then you can run gencov to get a coverage report to see what code is not being tested. Once you have added additional test cases, you can run go test -cover in the appropriate package to see the current coverage level.

    WARNING: Running the unit-tests may fail due to too many open file descriptors. Depending on where the failure occurs, the error message may not be obvious and may only say something similar to "unable to open database file". Depending on the settings on your host, you may need to increase the maximum number of open file descriptors. For example, the OSX default per-process maximum number of open file descriptors is 256. You may issue the following command to display your current setting:

    # ulimit -n

    And the following command will increase this setting to 65536:

    # ulimit -n 65536

    Please note that this change is only temporary. To make it permanent, you will need to consult the documentation for your host operating system.

Package overview

  1. cmd/fabric-ca-server contains the main for the fabric-ca-server command.
  2. cmd/fabric-ca-client contains the main for the fabric-ca-client command.
  3. lib contains most of the code. a) server.go contains the main Server object, which is configured by serverconfig.go. b) client.go contains the main Client object, which is configured by clientconfig.go.
  4. util/csp.go contains the Crypto Service Provider implementation.
  5. lib/dbutil contains database utility functions.
  6. lib/ldap contains LDAP client code.
  7. lib/spi contains Service Provider Interface code for the user registry.
  8. lib/tls contains TLS related code for server and client.
  9. util contains various utility functions.

Additional info

Profiling Fabric CA server

To enable profiling on the server, set the FABRIC_CA_SERVER_PROFILE_PORT environment variable to a valid, available port number and start the server. The server will start listening for profile requests at the /debug/pprof/ HTTP endpoint and the specified port. Then run go tool pprof with server's profiling URL (http://:/debug/pprof/<profile|heap|block>) as an argument, it will download and examine a live profile.

You can start the server in the FVT image by running following docker command from the fabric-ca root directory:

docker run -p 8888:8888 -p 8054:8054 -v $PWD:/opt/gopath/src/ -e FABRIC_CA_SERVER_PROFILE_PORT=8054 --name loadTest -td hyperledger/fabric-ca-fvt test/fabric-ca-load-tester/ 1

Then start the load by running /test/fabric-ca-load-tester/ -B

In other window, you can start profiling by running (assuming load test takes about a minute to complete):

curl http://localhost:8054/debug/pprof/profile?seconds=60 >

then analyze the profile:

go tool pprof bin/fabric-ca-server

OR simply run:

go tool pprof -seconds=60 http://localhost:8054/debug/pprof/profile

You can use commands like top, top -cum, list and web to look at the top consumers, list the code to see the hotspots and to view the graph in a browser. You can run go tool pprof -h to view all the options supported by the pprof tool

You can also use go-torch tool to analyze the profile:

go-torch bin/fabric-ca-server

Profiling Fabric CA client

To enable profiling on the client, set the FABRIC_CA_CLIENT_PROFILE_MODE environment variable to either "heap" or "cpu" to enable heap, cpu profiling respectively. A file containing profiling data is created in the present working directory of the client. Heap profiling data is written to mem.pprof and cpu profiling data is written to cpu.pprof. You can run go tool pprof <client executable> <profiling file> to analyze the profiling data.

Profiling links


See FVT tests for information on functional verification test cases.

Updating the cfssl vendored package

Following are the steps to update cfssl package using version 1.0.8 of govendor tool.

  • Remove cfssl from vendor folder

    • cd $GOPATH/src/
    • govendor remove
    • rm -rf
  • Clone cfssl repo

  • Add cfssl from $GOPATH to the vendor folder

    • cd $GOPATH/src/
    • govendor add^
    • You can optionally specify revision or tag to add a particular revision of code to the vendor folder
      • govendor add^@abc12032
  • Remove sqlx package from cfssl vendor folder. This is because certsql.NewAccessor (called by fabric-ca) requires sqlx.db object to be passed from the same package. If we were to have sqlx package both in fabric-ca and cfssl vendor folder, go compiler will throw an error

    • rm -rf
  • Remove the packages that are added to the fabric-ca vendor folder that are not needed by fabric-ca

Continuous Integration

Please have a look at Continuous Integration Process


Hyperledger Project source code files are made available under the Apache License, Version 2.0 (Apache-2.0), located in the LICENSE file. Hyperledger Project documentation files are made available under the Creative Commons Attribution 4.0 International License (CC-BY-4.0), available at

You can’t perform that action at this time.