'Adding/Configuring the Subject Alternative Name of the CA certificate in Hyperledger Fabric CA

I have a couple of Hyperledger Fabric networks (1.4 and 2.3+ versions) working OK but I have a annoying configuration problem with the CA.

The certificate for the CA that my artifacts generate (configtx.yaml) and (crypto-config.yaml) has as CN value "ca.myorg.org". This means that the CA only accepts requests to that host address. If I do a request to host "ca" (which is the host name created by the Kubernetes cluster) I get:

"hyperledger client doesn't match any of the subject alternative names" error from the CA instance.

I use Kubernetes to deploy the network and the service name are "ca", "peer1", ... so I cannot simply set ca.myorg.org as service name... this implies that I have to:

  1. Add a custom DNS alias in the Kubernetes inner DNS to map ca -> ca.myorg.org so I can run requests to ca.myorg.org from the Chaincode Java client pod. (requests to "ca" will be rejected by CA.
  2. When I run tests from outside the Kubernetes network, I need to use Kubefwd, which is OK, but that will create a local hosts entry "ca" in my computer... everytime I need to manually add that alias too to the hosts file. Very annoying.

My question is... how can I configure the artifacts so "ca" is also accepted as a Subject Alternative Name in the generated certificate for the CA? That would solve my problem.

As a work around, can I also alter the certificate adding the "ca" subject alternative name, after it's generated? That would work.

Of course, maybe I am missing something on all this artifact certificate generation when creating the Hyperledger Fabric network. I'm all ears for suggestions on what approach to take when the CA is going to be deployed in Kubernetes.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source