Skip to content

Commit 48d4971

Browse files
authored
Merge pull request #4 from devilbox/release-0.1
Release v0.1
2 parents 62bc2cf + 0a505d1 commit 48d4971

File tree

6 files changed

+158
-32
lines changed

6 files changed

+158
-32
lines changed

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
sudo: required
2+
3+
language: bash
4+
5+
before_install:
6+
# Add more modern repos
7+
- sudo apt-get update -qq
8+
- sudo apt-get install -qq python-software-properties
9+
- sudo add-apt-repository ppa:brightbox/ruby-ng -y
10+
- sudo add-apt-repository "deb http://archive.ubuntu.com/ubuntu/ trusty-backports restricted main universe"
11+
12+
# Update sources
13+
- sudo apt-get update -qqy
14+
15+
# Install
16+
- sudo apt-get install -qqy shellcheck
17+
18+
19+
script:
20+
21+
- shellcheck --shell=bash bin/ca-gen
22+
- shellcheck --shell=bash bin/cert-gen

Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Configuration
2+
SHELL = /bin/sh
3+
4+
MKDIR_P = mkdir -p
5+
6+
7+
help:
8+
@echo Options
9+
@echo " make install"
10+
@echo " Install everthing (requires sudo or root)"
11+
@echo ""
12+
@echo " make help"
13+
@echo " Show this help screen"
14+
15+
16+
install:
17+
18+
@echo "Installing files"
19+
@echo ""
20+
21+
@# Create directories
22+
${MKDIR_P} /usr/local/bin
23+
24+
@# Install binary
25+
install -m 0755 bin/ca-gen /usr/local/bin/ca-gen
26+
install -m 0755 bin/cert-gen /usr/local/bin/cert-gen
27+
28+
29+
@echo "Installation complete:"
30+
@echo "----------------------------------------------------------------------"
31+
@echo ""

README.md

Lines changed: 71 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,60 @@
11
# ca-gen
22

3+
[![Build Status](https://travis-ci.org/devilbox/cert-gen.svg?branch=master)](https://travis-ci.org/devilbox/cert-gen)
4+
[![Join the chat at https://gitter.im/devilbox/Lobby](https://badges.gitter.im/devilbox/Lobby.svg)](https://gitter.im/devilbox/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5+
![Tag](https://img.shields.io/github/tag/devilbox/ca-gen.svg)
6+
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
7+
38
Easily create your own CA and self-signed certificates.
49

5-
CA can be imported into Chrome, Firefox and Internet Explorer for local development.
10+
The generated CA can be imported into Chrome, Firefox or Internet Explorer for local development.
11+
All subsequent created certificates will then be valid SSL certificates to each browser.
12+
13+
<img width="200" style="width:200px;" src="img/address-bar.png" />
14+
15+
**Table of Contents**
16+
17+
1. [Available Tools](#available-tools)
18+
1. [Tools](#tools)
19+
2. [Requirements](#requirements)
20+
3. [Installation](#installation)
21+
2. [Create Certificate Authoriy](#create-certificate-authority)
22+
1. [Usage: ca-gen](#usage-ca-gen)
23+
2. [Execute: ca-gen](#execute-ca-gen)
24+
3. [Example: CA](#example-ca)
25+
3. [Create SSL Certificate](#create-ssl-certificate)
26+
1. [Usage: cert-gen](#usage-cert-gen)
27+
2. [Execute: cert-gen](#execute-cert-gen)
28+
3. [Example: SSL certificate](#example-ssl-certificate)
29+
4. [Import CA into Chrome](#import-ca-into-chrome)
30+
5. [License](#license)
31+
32+
----
633

734
## Available Tools
835

9-
* [ca-gen](bin/ca-gen)
10-
* [cert-gen](bin/cert-gen)
36+
#### Tools
1137

38+
| Tools | Description |
39+
|--------------------------|-------------|
40+
| [ca-gen](bin/ca-gen) | Creates a certificate authority |
41+
| [cert-gen](bin/cert-gen) | Creates SSL certificates signed by a certificate authority |
1242

13-
## Create CA
43+
#### Requirements
1444

15-
#### Devilbox example
45+
* `openssl`
46+
* `bash`
47+
48+
#### Installation
1649
```bash
17-
$ ca-gen -v -c DE -s Berlin -l Berlin -o Devilbox -u Devilbox -n devilbox.org \
18-
-e [email protected] devilbox-rootCA.key devilbox-rootCA.crt
50+
$ sudo make install
1951
```
2052

21-
#### Usage
53+
54+
## Create Certificate Authority
55+
56+
#### Usage: ca-gen
57+
The following shows the general usage for `ca-gen`:
2258
```bash
2359
USAGE: ca-gen -n CN [-kdcslouev] <keyfile> <crtfile>
2460
ca-gen --help
@@ -43,7 +79,14 @@ Required parameter
4379
<crtfile> Path to output cert file
4480
```
4581

46-
#### Example output
82+
#### Execute: ca-gen
83+
The following command shows how the CA is generated for the [Devilbox](https;//github.com/cytopia/devilbox):
84+
```bash
85+
$ ca-gen -v -c DE -s Berlin -l Berlin -o Devilbox -u Devilbox -n devilbox.org \
86+
-e [email protected] devilbox-rootCA.key devilbox-rootCA.crt
87+
```
88+
89+
#### Example: CA
4790
```bash
4891
Certificate:
4992
Data:
@@ -106,21 +149,10 @@ Certificate:
106149
```
107150

108151

109-
## Create certificate
110-
111-
#### Devilbox example
112-
```bash
113-
$ cert-gen -v -c DE -s Berlin -l Berlin -o Devilbox -u Devilbox \
114-
-n project.loc -e [email protected] \
115-
-a '*.project.loc,*.www.project.loc' \
116-
devilbox-rootCA.key \
117-
devilbox-rootCA.crt \
118-
project.loc.key \
119-
project.loc.csr \
120-
project.loc.crt
121-
```
152+
## Create SSL Certificate
122153

123-
#### Usage
154+
#### Usage: cert-gen
155+
The following shows the general usage for cert-gen:
124156
```bash
125157
USAGE: cert-gen -n CN [-kdcsloueav] <ca-key> <ca-crt> <key> <csr> <crt>
126158
cert-gen --help
@@ -149,7 +181,20 @@ Required parameter
149181
<crt> Path to output certificate crt file
150182
```
151183

152-
#### Example output
184+
#### Execute: cert-gen
185+
The following command shows how SSL certificates are generated for the [Devilbox](github.com/cytopia/devilbox):
186+
```bash
187+
$ cert-gen -v -c DE -s Berlin -l Berlin -o Devilbox -u Devilbox \
188+
-n project.loc -e [email protected] \
189+
-a '*.project.loc,*.www.project.loc' \
190+
devilbox-rootCA.key \
191+
devilbox-rootCA.crt \
192+
project.loc.key \
193+
project.loc.csr \
194+
project.loc.crt
195+
```
196+
197+
#### Example: SSL Certificate
153198
```bash
154199
Certificate:
155200
Data:
@@ -206,7 +251,8 @@ Certificate:
206251
02:db:c7:03
207252
```
208253

209-
## Import to Chrome
254+
255+
## Import CA into Chrome
210256

211257
**1. Open Chrome settings - scroll down and click `Advanced`**
212258

bin/ca-gen

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ fi
218218
###
219219

220220
# Subject dnQualifier (Public key thumbprint, see SMPTE 430-2-2006 sections 5.3.1, 5.4 and DCI CTP section 2.1.11)
221-
ca_dnq="$( openssl rsa -outform PEM -pubout -in "${CA_KEY_FILE}" | openssl base64 -d | dd bs=1 skip=24 2>/dev/null | openssl sha1 -binary | openssl base64 )"
222-
ca_dnq="$( echo "${ca_dnq}" | sed 's|/|\\/|g' )" # can have values like '0Za8/aABE05Aroz7le1FOpEdFhk=', note the '/'. protect for name parser
221+
ca_dnq="$( openssl rsa -outform PEM -pubout -in "${CA_KEY_FILE}" 2>/dev/null | openssl base64 -d | dd bs=1 skip=24 2>/dev/null | openssl sha1 -binary | openssl base64 )"
222+
ca_dnq="${ca_dnq//\//\\/}" # echo "${ca_dnq}" | sed 's|/|\\/|g' )" # can have values like '0Za8/aABE05Aroz7le1FOpEdFhk=', note the '/'. protect for name parser
223223
SUBJECT="${SUBJECT}/dnQualifier=${ca_dnq}"
224224

225225

@@ -260,5 +260,18 @@ fi
260260
###
261261
### 4. Validate
262262
###
263-
openssl x509 -in "${CA_CRT_FILE}" -text
264-
openssl x509 -noout -subject -issuer -in "${CA_CRT_FILE}"
263+
if ! out="$( openssl x509 -in "${CA_CRT_FILE}" -text )"; then
264+
echo "${out}"
265+
exit 1
266+
fi
267+
if [ "${DEF_VERBOSE}" = "1" ]; then
268+
echo "${out}"
269+
fi
270+
271+
if ! out="$( openssl x509 -noout -subject -issuer -in "${CA_CRT_FILE}" )"; then
272+
echo "${out}"
273+
exit 1
274+
fi
275+
if [ "${DEF_VERBOSE}" = "1" ]; then
276+
echo "${out}"
277+
fi

bin/cert-gen

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,11 @@ fi
255255
###
256256

257257
# Command
258+
# shellcheck disable=SC1117
258259
cmd=" openssl x509 \
259260
-req \
260261
-extensions v3_req \
261-
-extfile <(printf '[ req ]\nreq_extensions = v3_req\n[ v3_req ]\nsubjectAltName=${ALT_NAMES}') \
262+
-extfile <(printf '[ req ]\nreq_extensions = v3_req\n[ v3_req ]\nsubjectAltName=${ALT_NAMES}'\n) \
262263
-days ${DEF_DAYS} \
263264
-in ${CSR_FILE} \
264265
-CA ${CA_CRT_FILE} \
@@ -287,5 +288,18 @@ fi
287288
###
288289
### 4. Validate
289290
###
290-
openssl x509 -in "${CRT_FILE}" -text -noout
291-
openssl verify -verbose -CAfile "${CA_CRT_FILE}" "${CRT_FILE}"
291+
if ! out="$( openssl x509 -in "${CRT_FILE}" -text -noout )"; then
292+
echo "${out}"
293+
exit 1
294+
fi
295+
if [ "${DEF_VERBOSE}" = "1" ]; then
296+
echo "${out}"
297+
fi
298+
299+
if ! out="$( openssl verify -verbose -CAfile "${CA_CRT_FILE}" "${CRT_FILE}" )"; then
300+
echo "${out}"
301+
exit 1
302+
fi
303+
if [ "${DEF_VERBOSE}" = "1" ]; then
304+
echo "${out}"
305+
fi

img/address-bar.png

4.92 KB
Loading

0 commit comments

Comments
 (0)