Skip to content

Instantly share code, notes, and snippets.

@gnilchee
Created August 4, 2017 05:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gnilchee/6ab801ffde88242fd440ee3c671a361e to your computer and use it in GitHub Desktop.
Save gnilchee/6ab801ffde88242fd440ee3c671a361e to your computer and use it in GitHub Desktop.
Create Your Own CA
{
"signing": {
"default": {
"expiry": "17520h"
},
"profiles": {
"2yr-server": {
"expiry": "17520h",
"usages": [
"signing",
"key encipherment",
"server auth"
]
},
"3yr-server": {
"expiry": "26280h",
"usages": [
"signing",
"key encipherment",
"server auth"
]
},
"5yr-server": {
"expiry": "43800h",
"usages": [
"signing",
"key encipherment",
"server auth"
]
},
"2y-client": {
"expiry": "17520h",
"usages": [
"signing",
"key encipherment",
"client auth"
]
},
"3y-client": {
"expiry": "26280h",
"usages": [
"signing",
"key encipherment",
"client auth"
]
},
"5y-client": {
"expiry": "43800h",
"usages": [
"signing",
"key encipherment",
"client auth"
]
}
}
}
}
{
"CN": "My CA",
"hosts": [
"myca.com",
"www.myca.com"
],
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "US",
"ST": "CA",
"L": "San Francisco"
}
],
"ca": {
"expiry": "87600h"
}
}
{
"CN": "host.example.com",
"hosts": [
"host.example.com"
],
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "US",
"ST": "CA",
"L": "Oakland"
}
]
}

Install cfssl

go get -u github.com/cloudflare/cfssl/cmd/cfssl

Install support binaries

go get -u github.com/cloudflare/cfssl/cmd/...

Create CA

cfssl gencert -initca ca-csr.json | cfssljson -bare ca -

Sign your first server cert

cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=2yr-server host.example.com.json | cfssljson -bare host.example.com

To see more details on this process

More Information

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment