Using openssl to generate certificate and key for use with Hyperledger Fabric

Create a text file fabric.cnf with following contents


[ req ]

#default_bits = 2048

#default_md = sha256

#default_keyfile = privkey.pem

distinguished_name = req_distinguished_name

attributes = req_attributes

x509_extensions = v3_ca

[ req_distinguished_name ]

countryName = Country Name (2 letter code)

countryName_min = 2

countryName_max = 2

stateOrProvinceName = State or Province Name (full name)

localityName = Locality Name (eg, city)

0.organizationName = Organization Name (eg, company)

organizationalUnitName = Organizational Unit Name (eg, section)

commonName = Common Name (eg, fully qualified host name)

commonName_max = 64

emailAddress = Email Address

emailAddress_max = 64

[ req_attributes ]

challengePassword = A challenge password

challengePassword_min = 4

challengePassword_max = 20

[ v3_ca ]

keyUsage=critical,keyCertSign,cRLSign

basicConstraints=critical,CA:true,pathlen:1

subjectKeyIdentifier=hash

Now on the command line run:


$ openssl req -new -x509 -nodes -newkey ec:<(openssl ecparam -name prime256v1) -keyout ca.key -out ca.crt -days 3650 -config fabric.cnf

Verify:

$ openssl x509 -in ca.crt -text -noout

This entry was posted in Software. Bookmark the permalink.

Leave a Reply