NCKU Blockchain
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Owners
          • Signed-in users
          • Everyone
          Owners Signed-in users Everyone
        • Write
          • Owners
          • Signed-in users
          • Everyone
          Owners Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Write
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Fabric Certification Authority ## Hyperledger Fabric Identity Management - CA ![](https://i.imgur.com/I9TWDfx.png) Agents of trusted certification authorities refer to Registrar who issue the identities and assign privileges to the identities they create - Creation process - Step 1. Registrar generates Enrollment ID and Enrollment Secret (securely provided to the End User). - Step 2. Enrollment process leads to the generation of the certificate for the End User. - Specifications - Name: /** Free string **/ - Type: /** Represents type **/ (peer, orderer, client ...) ![](https://i.imgur.com/6Xz58wZ.png) - Affiliation: /** Organization **/ ![](https://i.imgur.com/GwsonTu.png) - Max Enrollments: /** Max Re-enrollment count **/ (How many times the identity owner can execute the end rule step, the subsequent calls to end rule is referred to as re-enrollment) - Attributes: [ /** Standard | Custom **/ ] (the privileges assigned to the identity) ![](https://i.imgur.com/eabn9e5.png) ## Hyperledger Fabric CA Components The Registrar and the Admin use the CA Client for creating and managing identityies on the CA Server. The Developers or the Users car write applications using the CA SDK to interact with the CA Server ![](https://i.imgur.com/TEUqyWK.png) - CA Server Exposes Certificate Creation & Management services - Admin and registrar: - Identity | Certificate Management - Register - Affiliation Management - Revocations - User: - Enroll - Re-enroll CA Server exposes there services as API, then you can write own applications using any language or library to invoke these API. The specification for these API are available in `swagger` format. - CA Client Utility for interaction with CA server - CA SDK Client libraries for writing apps ## Configuring and Launching the CA Server CA server is available as a single binary(likes peer and orderer) - `fabric-ca-server`. It can be launched as: - Single process setup (single point of failure) - Cluster setup fabric-ca-server command: `fabric-ca-server command --flags` - `version` Version of the binary - `init` Initialize the CA Server It is similar to `start` but it does not launch the CA Server ![](https://i.imgur.com/H13aQwX.png) - `start` - Launches the CA Server process - Config may be provided by way of flags | environment | YAML(`fabric-ca-server-config`) ![](https://i.imgur.com/atnInKp.png) - A server may contain multiple CAs. Each CA is either a root CA or an intermediate CA. Each intermediate CA has a parent CA which is either a root CA or another intermediate CA. - --flags: - `--help` Help documents - `-d --debug` To enable debug level logging - `-b --boot` Bootstrap new identity - `--address` Listening address. Default = 0.0.0.0 - `-p` Listening port. Default = 7054 - `-n --ca.name` Name for the CA - `Certificate` CA certificate setup - `TLS` Transport Layer Security - `CSR` Certificate Signing Request - `Database` DB config for cluster setup - `LDAP` LDAP Config for cluster setup - `Intermediate CA` ICA Configuration Launch without initialization(for test): `fabric-ca-server start -b admin:adminpw` First time start initializes the CA server will generate the Config file(`fabric-ca-server-config.yaml`) and CA Certificate & Key. Location of the YAML: 1. Specified by way of `-h` flag 2. Environment variable `FABRIC_CA_SERVER_HOME` 3. Environment variable `FABRIC_CA_HOME` 4. Environment variable `CA_CFG_PATH` 5. Current Folder All of the Identities on the CA server are managed in a persistent store, by default `SQLite`.(can replace by other database) :::info ### Exercise: Expolre the CA server 1. Launch the CA server with default configuration - Open terminal window and switch to folder: `ca/server` `fabric-ca-server start -b admin:adminpw` 3. Expolore the REST APL swagger - https://raw.githubusercontent.com/acloudfan/HLF2-Miscellaneous/master/fabric-ca-swagger.yaml - swagger: Copy & Paste Swager JSON to editor & expolore https://editor.swagger.io/ ::: ### fabric-ca-server-config.yaml - . - `version` Version of the server - `port` Port on which the server listens for incoming REST requests. Default=7054 - `crlsizelimit` CRL size limit. Default=512000 - `debug` Enable/Disable Debug level logging Root Certificate Specifications - `ca` Certification Authority information - `csr` Certificate Signing Request Intermediate CA Setup - `intermediate` Intermediate CA Server Setup Identity enrollment - `affiliations` CA server affiliations - `sigining` Certificate Signing Configuration Identity persistence - `registry` Registry for managing identities - `db` Database configuration SQLit, MySQL, PostgreSQL - `Idap` CA server affiliations Sections - `tls` Transport Layer Security - `crl` Certificate Revocation List - `bccsp` Blockchain Crypto Service Provider Multiple Certification Authorities (Single CA Server process may host multiple CA) - `cacount` Count of the CA - `cafiles` Files related to each of the CA :::info ### Recipe: Standalone Root CA Server setup - Suppose - All of commands are demonstrated under the folder `ca/server` - Single CA for Acme and Orderer organization - Use default database for identity persistence SQLite - TLS = Disabled - CSR ![](https://i.imgur.com/N1D6Iqh.png) - Step 1. Setup the parameters in `fabric-ca-server-config.yaml` Provide values for parameters under four sections - `ca` ![](https://i.imgur.com/huGTA77.png) - `affiliations` ![](https://i.imgur.com/4ShmUOT.png) - `registry` ![](https://i.imgur.com/fIiJmyl.png) - `csr` ![](https://i.imgur.com/bQdOqA4.png) 3. Execute the init command Before step.2: Execute ./clean.sh and copy `fabric-ca-server-config.yaml` to `ca/server` - `fabric-ca-server init` - `fabric-ca-server start` 5. Examine the Root Certificate - Copy the content of `ca-cert.pem` to the [decoder web](https://certlogik.com/decoder/) to decode CSR ::: ## Fabric CA Client - Single binary file `fabric-ca-client` picks up configuration from `fabric-ca-client-config.yaml` - Needs access to crypto material for the identity that it uses for interacting with the CA Server - Home folder | Location of the `fabric-ca-client-config.yaml` 1. Specified by way of `-h` flag 2. Environment variable `FABRIC_CA_CLIENT_HOME` 3. Environment variable `FABRIC_CA_HOME` 4. Environment variable `CA_CFG_PATH` 5. Folder $HOME/.fabric-ca-client - Commands: fabric-ca-client command --flags - `fabric-ca-client version` - --help - `fabric-ca-client --help` - `fabric-ca-client command --help` - `getcainfo` Gets the CA information - `identity` Manage the identities - `enroll` Enroll an identity - `reenroll` RE-Enroll an identity - `register` Registers an identity - `affiliation` Manage affiliations - `revoke` Revoke identity - `gencrl` Generate Certificate Revocation List - `gencsr` Generate a Certificate Signing Request - `certificate` Manage certificate - Enroll 1. `fabric-ca-server start -b admin:adminpw` Register admin identity 2. `fabric-ca-client enroll -u http://admin:adminpw@localhost:7054` First execution will generates `fabric-ca-client-config.yaml` in CA Client HOME folder 3. Sets up MSP directory in CA Client HOME folder - Re-Enroll `fabric-ca-client rennroll` - Regeneration of the certificate & keyfile, it changes the content of the certificate - Number of times re-enroll can be invoked in the `fabric-ca-client-config.yaml`(Max Enrollments=-1 unlimited use secret) :::info ### Enroll the bootstrap identity - `fabric-ca-server start` (terminal 1) - `export FABRIC_CA_CLIENT_HOME='pwd'`(terminal 2) - `fabric-ca-client enroll -u http://admin:adminpw@localhost:7054` (terminal 2) ### Exercise: Explore the CA Client setup - Pre work & solution - `ca` >_ `./clean.sh all` Cleanup the previous run - Copy server config file to `ca/server` 1. Add an additional bootstrap identity (user) - Update the CA Server Configuration (`fabric-ca-server-config.yaml`) - registry: Not a Registrar and should not be able to generate CRL. - Type=user - Credentials=user:userpw - Maxenrollment=2 - `fabric-ca-server start` 3. Enroll the bootstrap identity (admin & user) Execute commands in ca folder - Enroll admin - `setclient.sh admin` - `fabric-ca-client enroll -u http://admin:adminpw@localhost:7054` - Enroll user - `setclient.sh user` - `fabric-ca-client enroll -u http://user:userpw@localhost:7054` 5. Call enroll command multiple times for user - Execute once - `setclient.sh user` - Exucute more than 2 times - `fabric-ca-client enroll -u http://user:userpw@localhost:7054` - It should fail(Error Code: 20 - Authorization failure) 7. Examine the `ca-cert.pem` for the user Copy user's cert.pem to the Decoder ::: ## Attribute Based Access Control (ABAC) & Identity Commands - Standard attributes - Fabric Runtime Access control - Specification elements added as attributes (default) ![](https://i.imgur.com/TEYXsND.png) - Custom attributes Registrar can add custom attributes as well - Application Level Access control - Accessible from Chain code - Defaults for the bootstrap admin identity `fabric-ca-server start -b admin:adminpw` ![](https://i.imgur.com/Idm2y6P.png) The Ecert set to false means that these attributes are not added to the enrollment certificate - By default only 3 attributes added to the certificate Standard | custom attributes by default are NOT included in the certificate need explicitly requested for attribute to be added to certificate that is how the chain code will get access to the attributes for decision making process. - hf.EnrollmentID Value:user ECert:true - hf.Type Value:user ECert:true - hf.Affiliation Value:org2 ECert:ture That means these attributes will be available in the chain code. - commands Registrar use `identity` command for managing identities on the CA Server - `fabric-ca-client identity list` List the identities - `fabric-ca-client identity remove <enrollment ID>` By default identity removal is DISABLED To ENABLE identity removal start the CA server with`--cfg.identities.allowremove` - `fabric-ca-client identity add <enrollment-ID> --flags` Add an identity ![](https://i.imgur.com/b9bstGg.png) OR use a JSON String `--json JSON String` - `fabric-ca-client identity modify <enrollment-ID> --flags` Modify an identity - e.g.`fabric-ca-client identity modify user --attrs myAttr true:ecert` To add the attribute to ECert suffix the value with :ecert :::info ### Exercise: Manage User Identities 1. Launch the CA server & Enroll admin identity 3. List the identities using `identity list` command `fabric-ca-client identity list` 4. Add 2 new identities of `type = user` and default attributes User - Use the specification flags User1 - Use the JSON string `fabric-ca-client identity add user --type user --affiliation org1 --maxenrollments 2` `fabric-ca-client identity add user1 --json '{"type":"user", "affiliation":"org1","maxenrollments":2}'` 4. Modify affiliation of the user to `org2` & add a custom attribute `fabric-ca-client identity modify user --affiliation org2 --attrs maAttr=ture` 6. `Remove` the user1 and then use `list` command to confirm Server restart will be needed `fabric-ca-client identity start --cfg.identities.allowremove` (change terminal) `fabric-ca-client identity remove user1` 6. `Modify` custom attribute such that its added to the `ECert` `fabric-ca-client identity modify user --affiliation org2 --attrs myAttr-ture:ecert` ::: ## Identity Management Rules `fabric-ca-client register --flags` similar to `fabric-ca-client identity add --flags` except that `--flags` are different ![](https://i.imgur.com/u0bjJLj.png) - Runtime applies ABAC (Affiliation & Attributes) to check - Registrar's identity MUST be enrolled - Identity Registration Checks: 1. Can create an identity of Requested Type? Registrar's identity MUST have Roles attribute `hf.Registrar.Roles` - Comma separated list of identity types - Governs type of user Registrar can create Example: - hf.Registrar.Roles="peer,app,user" - hf.Registrar.Roles="orderer" - hf.Registrar.Roles="*" (all) ![](https://i.imgur.com/sXu9JQq.png) 3. Can assign the Requested Affiliation? Registrar's Affiliation MUST be equal or above - New identity Affiliation = Registrar's Affiliation - Registrar's Affiliation is a Prefix of new identity ![](https://i.imgur.com/xHmrz1y.png) 5. Can add/change the Requested Standard Attribute? Multiple Rules applied for Standard attributes ![](https://i.imgur.com/d5aa9zi.png) 7. Can add/change the Requested Custom Attribute? Multiple Rules applied for Custom attributes - Specifies patterns for `attrs` that Registrar is allowed to manage ![](https://i.imgur.com/Vpr5qiL.png) 9. Can add/change the value of hf.Registrar.Attributes? Setting | Adding the hf.Registrar.Attributes - Value may be equal to or subset of hf.Registrar.Attributes - May be specified as patterns ![](https://i.imgur.com/WVzxkfA.png) ## Fabric CA client YAML Configuration `fabric-ca-client enroll` will use the configuration information from `fabric-ca-client-config.yaml`, so it will read URL for server - `url` URL of the CA Server - `caname` Name of the CA Server if multiple CA hosted in server - `msp` Folder path to msp directory - `csr` Certificate Singing Request User generate a CSR by` fabric-ca-client generate` 1. CA Client prepares the CSR and sends it to the fabric CA Server 2. CA Server reads the CSR to sign the certificate and sends certificate to CA Client 3. CA client on receiving the signed certificate observe to the MSP 4. CA client can set up the parameters in the CSR to ensure that the certificate reflects the information about their organization - `tls` Transport Layer Security - `certfiles` List of trusted Root Certificate file - `client` Needed if client auth enabled on server - `cerfile` Client Cert/Pem file - `keyfile` Client Key/Pem file - `id` Used by Register commands - `name` Override this with `--id.name` flag - `type` Override this with `--id.type` flag - `affiliation` Override this with `--id.affiliation` flag - `maxenrollment` Override this with `--id.maxenrollment` flag - `attributes` Override this with `--id.attributes` flag. List of name-value

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully