Skip to content

Instantly share code, notes, and snippets.

@arusso
Created April 1, 2013 17:12
Show Gist options
  • Save arusso/5286250 to your computer and use it in GitHub Desktop.
Save arusso/5286250 to your computer and use it in GitHub Desktop.
Host CNF file for certificate request generation. Includes support for SAN certs
[ req ]
default_bits = 2048
default_md = sha1
distinguished_name = req_distinguished_name
prompt = no
<% if @alt_names_real.count > 1 -%>
x509_extensions = v3_ca # The extentions to add to the self signed cert
req_extensions = v3_req # The extensions to add to a certificate request
<% end -%>
[ req_distinguished_name ]
C=<%= @country %>
ST=<%= @state %>
L=<%= @city %>
O=<%= @org %>
OU=<%= @org_unit %>
CN=<%= @cn %>
[ v3_req ]
basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
subjectAltName = @alt_names
[ v3_ca ]
subjectKeyIdentifier=hash
authorityKeyIdentifier=keyid:always,issuer:always
basicConstraints = CA:true
subjectAltName = @alt_names
[ alt_names ]
<% idx=0 -%>
<% @alt_names_real.each do |alt| -%>
DNS.<%= idx %> = <%= alt %>
<% idx+=1 -%>
<% end -%>
@arusso
Copy link
Author

arusso commented Apr 1, 2013

country is 2 character country code
state is full state name
city is the full city name
org is the full org name
ou is the department/division name. probably optional
cn is the primary fqdn of the host
alt_names_real is an array of alternate names. 

ie.
@Country = 'US'
@State = 'NY'
@city = 'New York'
@org = 'Example dot Shh dot Com'
@ou = 'Infrastructure Destruction Team'
@cn = 'foo.shh.example.com'
@alt_names_real = [ 'foo.example.shh.com', 'bar.example.shh.com' ]

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