easy-rsa/f174800.patch

32 lines
965 B
Diff
Raw Normal View History

From d309c6aaa23f661ccd2563df6a184e1351293b61 Mon Sep 17 00:00:00 2001
From: ValdikSS <iam@valdikss.org.ru>
Date: Mon, 11 Jan 2016 01:53:32 +0300
Subject: [PATCH] Generate random serial number for all certificates
---
easyrsa3/easyrsa | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/easyrsa3/easyrsa b/easyrsa3/easyrsa
index 6fec288..bcb3aeb 100755
--- a/easyrsa3/easyrsa
+++ b/easyrsa3/easyrsa
@@ -652,6 +652,17 @@ Certificate created at: $crt_out
build_full() {
verify_ca_init
+ local i= serial= check_serial=
+ for i in 1 2 3 4 5; do
+ "$EASYRSA_OPENSSL" rand -hex 16 -out "$EASYRSA_PKI/serial"
+ serial="$(cat "$EASYRSA_PKI/serial")"
+ check_serial="$("$EASYRSA_OPENSSL" ca -config "$EASYRSA_SSL_CONF" -status "$serial" 2>&1)"
+ case "$check_serial" in
+ *"not present in db"*) break ;;
+ *) continue ;;
+ esac
+ done
+
# pull filename base:
[ -n "$2" ] || die "\
Error: didn't find a file base name as the first argument.