Skip to main content

How to Setup the Hyperledger Fabric-ca Client Setup on Ubuntu 16.04 - Part 3

How to Setup the Hyperledger Fabric-ca Client Setup on Ubuntu 16.04 - Part 3

This article is about the steps needed to setup your own CA Server and register/enroll new users into your database. The server provides the public/private key pair as a response to enrolling the user into the database. If you need help to configure the requirements to download Hyperledger, check out the first article in this three part tutorial series to learn Hyperledger. If you need help to set up your Hyperledger server check out the second article in this series.
Now, that we have our server setup, we want to enroll existing and register new clients to the database. Let’s move on to it.
Just as we build the fabric-ca-server command in the Fabric-CA directory, we need to do the same for the fabric-ca-client to access commands for the client side. Use the following command in the root directory of your fabric-ca cloned project:
make fabric-ca-client 
You should see the output similar to the one mentioned below and should see a new executable in the bin directory of fabric-ca.
Hyperledger Client setup
For this part of the tutorial, we use the FABRIC_CA_CLIENT_HOME variable. Please add the following lines to the end of .bashrc file and reload the file too. The lines are:
export FABRIC_CA_HOME=~/Documents/Fabric-CA
export FABRIC_CA_CLIENT_HOME=$FABRIC_CA_HOME/client

You can initialise the variable with any directory you feel like doing. But, we assume that you have already set your FABRIC_CA_CLIENT_HOME variable for the rest of the tutorial.
To check, whether your fabric-ca-client is accessible or not, just type:
fabric-ca-client 
And you should see a similar output:
Hyperledger Client Output
Now, we know that from our server configuration, we have an admin user already registered into the database since the start of the server. So, we will use that credentials to enroll our admin user first and retrieve the public/private key pair to be able to register new users afterwards.
We use the following command:
fabric-ca-client enroll -u “http://admin:adminpw@localhost:7054” 

The “admin:adminpw” is actually a “username:password” pair which we need to send to localhost:7054, the default server url and port, our server listens to. If everything goes well, you should see the following output:
Hyperledger Client Admin Output
Now, that we have successfully enrolled the admin user, we have cert.pem (public key) and key.pem (private key) of the user. Also, as we were using this for the first time, we have the config file, fabric-ca-client-config.yaml, in the directory mentioned in the output.
Let us discuss some important fields in the fabric-ca-client-config.yaml file:
  • The “URL” field defines the default URL to connect to the server. It can be custom specified by the “-u” flag in the fabric-ca-client command.
  • The “TLS” section defines the tls configuration, required for secure connection to the server and ensure privacy over the internet. But, as we were using localhost in the system, there was no need to tls and so it was disabled by-default.
  • The“CSR” field is the “Certificate Signing Request”, which is sent to the server to sign the certificates with the provided details only. By-default, there are some values provided, but can be edited according to the needs.
  • The“Id” section defines the defails of a new user we want to register. This field eliminates the need to provide command line arguments as mentioned below in the tutorial. We use command line to ensure no error in the config file.
  • The “Enrollment” section as defined in the config file, is used to enroll any user with the appropriate details, stored in the server DB.
Now, we have to create a new user and register it. For that, we need to use the following command:
fabric-ca-client register -u “http://localhost:7054” --id.name “mlgblockchain” --id.secret “mlg” --id.type “client” --id.affiliation “org1.department1” 
When you run this command, you should see the following output upon successful execution:
Register User Hyperledger Fabric
Now, we have registered our new user “mlgblockchain”, with the following values:
  • --id.name - The name of the user.
  • --id.secret - The password for the user to enroll.
  • --id.affiliation - The organization and department the user is affiliated to. Mainly to segregate the user permissions.
  • --id.type - The type of the user. We are using “client”, but a user can be peer, validator, auditor, ca, etc.
Now, that we have registered our new user, we need to enroll into the server to get the public / private keys for the user “mlgblockchain”.
So we use the following command:
fabric-ca-client enroll -u “http://mlgblockchain:mlg@localhost:7054” 
If all goes well, you should see the following output:
Encoll Client Hyperledger Fabric
So, upon successful enrollment of the user, you shall receive the keys in the directory mentioned in the output.
Congrats! Finally, you are able to setup your own CA Server for the enrollment and signing of new Users required for your application.

CourtesyAkarsh Agarwal
Original Source : https://mlgblockchain.com/setup-hyperledger-client.html

Comments

Popular posts from this blog

Setup a Multi-Protocol VPN Server Using SoftEther on Centos7

  Introduction This article explains how to install and configure a multi-protocol VPN server using the SoftEther package. We enable and configure OpenVPN and L2TP over IPSec and SSTP VPN Servers on Linux. What is SoftEther SoftEther VPN is one of the world’s most powerful and easy-to-use multi-protocol VPN software, made by the good folks at the University of Tsukuba, Japan. It runs on Windows, Linux, Mac, FreeBSD and Solaris and is freeware and open-source. You can use SoftEther for any personal or commercial use free of charge. Step 1: Create a Virtual Server First, you need to create a DigitalOcean Droplet. As mentioned in SoftEther’s website, SoftEther will work on almost every Linux distro with kernel v2.4 or above,; however it’s recommended to choose one of these distributions: CentOS, Fedora, or Red Hat Enterprise Linux. Personally I have tried it on Ubuntu, CentOS and Fedora, both 32 and 64 bit editions, and it has worked perfectly. Step 2: Update your Server Software Usin...

Setting Up MariaDB MaxScale Binlog Proxy for backup/failover

  Setting Up MariaDB MaxScale Binlog Proxy MariaDB MaxScale Binlog Server acts as an intermediate master replication proxy. By storing binary logs and serving them to replicas, it enables scalable replication architectures, reduces primary database load, and accelerates disaster recovery. Step 1: Install MariaDB MaxScale Install MaxScale using the package manager appropriate for your Linux distribution, then verify the installation. On Ubuntu/Debian: sudo apt-get update sudo apt-get install maxscale On RHEL/CentOS: sudo yum install maxscale Verify the installation: maxscale --version Step 2: Configure MaxScale as a Binlog Proxy Open MaxScale's core configuration file to establish the routing properties and specify your database backend configuration. sudo nano /etc/maxscale.cnf Add the following configurations for the moni...

Deploying a laravel app using nginx alias

  server { listen 80; server_name subdomian.example.com; root /var/www/mainapp/; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; index index.html index.htm index.php; charset utf-8; error_log /var/log/nginx/error.log warn; location / { try_files $uri $uri/ /index.php?$query_string; } location = /favicon.ico { access_log off; log_not_found off; } location = /robots.txt { access_log off; log_not_found off; } error_page 404 /index.php; location ~ \.php$ { fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; } location /laravelapp { alias /var/www/mainapp/laravelapp/public; index index.php index.html in...