From dfbf9d0b491b97c146f2bc0bb58871db0c3b00f8 Mon Sep 17 00:00:00 2001 From: Miguel Alvarez Date: Tue, 16 Jul 2024 11:12:45 +0100 Subject: [PATCH] generate random 128 bit serial --- resources/libraries/helper.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/resources/libraries/helper.rb b/resources/libraries/helper.rb index 7ac32cc..e4f921c 100644 --- a/resources/libraries/helper.rb +++ b/resources/libraries/helper.rb @@ -3,6 +3,7 @@ module Helper require 'openssl' require 'resolv' require 'base64' + require 'securerandom' def create_cert(cn) # Return a hash with private key and certificate in x509 format @@ -10,7 +11,7 @@ def create_cert(cn) name = OpenSSL::X509::Name.parse "CN=#{cn}/DC=redborder" cert = OpenSSL::X509::Certificate.new cert.version = 2 - cert.serial = 0 + cert.serial = SecureRandom.random_number(2**128) cert.not_before = Time.now cert.not_after = Time.now + (3600 * 24 * 365 * 10) cert.public_key = key.public_key