Skip to content

Commit 49d3c55

Browse files
author
Matthieu Fronton
committed
first commit
0 parents  commit 49d3c55

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.crt
2+
*.key

README.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# frntn/x509-san
2+
3+
Generate a valid, self-signed, x509v3 certificate for multiple URLs / IPs
4+
5+
## Generate
6+
7+
The following command will generate (and overwrite if they already exists) two files:
8+
- pkcs#8 private key : `frntn-x509-san.key`
9+
- x509v3 certificate : `frntn-x509-san.crt`
10+
11+
```bash
12+
curl -sSL https://raw.githubusercontent.com/frntn/x509-san/master/gencert.sh | CRT_CN="client.com" CRT_SAN="DNS.1:www.client.com,DNS.2:admin.client.com,IP.1:192.168.1.10,IP.2:10.0.0.234" bash
13+
```
14+
15+
**=> Change the `CRT_CN` and `CRT_SAN` values to fit your needs**
16+
17+
## Check
18+
19+
You can check the certificate content by using the following standard `x509` command :
20+
21+
```bash
22+
openssl x509 -in frntn-x509-san.crt -noout -text
23+
```
24+
25+
## Secure the private key
26+
27+
The generated private key is passwordless by default.
28+
29+
You can secure/unsecure using standard `pkcs8` commands :
30+
31+
```bash
32+
# secure
33+
openssl pkcs8 -in frntn-x509-san.key -topk8 -v2 des3 -out frntn-x509-san.secure.key
34+
35+
unsecure
36+
openssl pkcs8 -in frntn-x509-san.secure.key -topk8 -nocrypt -out frntn-x509-san.key
37+
```
38+

gencert.sh

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/bin/bash
2+
3+
:<<-USAGE
4+
See https://github.com/frntn/x509-san/blob/master/README.md
5+
USAGE
6+
7+
certname="frntn-x509-san"
8+
openssl x509 -in <(openssl req -days 3650 -newkey rsa:4096 -nodes -keyout "${certname}.key" -subj "/C=FR/L=Paris/O=Ekino/OU=DevOps/CN=${CRT_CN:-"base.example.com"}") -req -signkey "${certname}.key" -days 3650 -out "${certname}.crt" -extfile <(echo "subjectAltName=${CRT_SAN:-"DNS.1:logs.example.com,DNS.2:metrics.example.com,IP.1:192.168.0.1,IP.2:10.0.0.50"}")

0 commit comments

Comments
 (0)