Master CFSSL: Step‑by‑Step Guide to Generate Self‑Signed Certificates on Linux
This comprehensive tutorial explains the fundamentals of PKI, CA, CSR, and cfssl configuration, shows how to install cfssl on Linux, details the cfssl gencert command and its core parameters, and provides practical, end‑to‑end examples for creating root, intermediate, server, client, and Kubernetes certificates.
CFSSL Self‑Signed Certificate Tool Overview
Certificate generation basics
Linux installation of cfssl
cfssl gencert command details and core parameters
Practical steps:
Create root CA configuration and CSR
Generate root CA certificate and key
Create intermediate CA CSR and generate intermediate CA certificate
Generate server certificate using intermediate CA
Generate client certificate
Generate Kubernetes certificates (API server, etc.)
Installation
Download cfssl, cfssljson, and cfssl‑certinfo binaries and grant execution permission.
curl -L -o /usr/local/bin/cfssl https://pkg.cfssl.org/R1.2/cfssl_linux-amd64
curl -L -o /usr/local/bin/cfssljson https://pkg.cfssl.org/R1.2/cfssljson_linux-amd64
curl -L -o /usr/local/bin/cfssl-certinfo https://pkg.cfssl.org/R1.2/cfssl-certinfo_linux-amd64
chmod +x /usr/local/bin/cfssl*cfssl gencert command
Core parameters include -ca, -ca-key, -config, -profile, -hostname, -cn, -key-algo, -key-size, -initca, -self-signed, etc.
Root CA generation
cfssl gencert -initca ca-csr.json | cfssljson -bare caProduces ca.pem, ca-key.pem, and ca.csr.
Intermediate CA generation
cfssl gencert -ca=ca/ca.pem -ca-key=ca/ca-key.pem -config=ca-config.json -profile=ca intermediate-csr.json | cfssljson -bare intermediate/intermediateServer certificate generation
cfssl gencert -ca=intermediate/intermediate.pem -ca-key=intermediate/intermediate-key.pem -config=ca-config.json -profile=server server-csr.json | cfssljson -bare server/serverClient certificate generation
cfssl gencert -ca=intermediate/intermediate.pem -ca-key=intermediate/intermediate-key.pem -config=ca-config.json -profile=client client-csr.json | cfssljson -bare client/clientKubernetes certificates
Example for API server:
cfssl gencert -ca=intermediate/intermediate.pem -ca-key=intermediate/intermediate-key.pem -config=ca-config.json -profile=kubernetes k8s-apiserver-csr.json | cfssljson -bare api-server/api-serverThe resulting directory tree shows generated CA, intermediate, server, client, and Kubernetes certificates.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Raymond Ops
Linux ops automation, cloud-native, Kubernetes, SRE, DevOps, Python, Golang and related tech discussions.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
