Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
#!/usr/bin/env bash

passphrase='changeme'
subject_base="/C=US/ST=California/L=San Francisco/O=MohanashreeFantasy Corp"
num_clients=3  # Define the number of clients

# Generate CA certificate
openssl genpkey -algorithm RSA -out ca_key.pem
openssl req -x509 -new -nodes -key ca_key.pem -sha256 -days 365 -out ca_cert.pem \
  -subj "$subject_base/CN=MohanashreeFantasy CA"

# Loop to generate client keys and certificate signing requests (CSRs)
for i in $(seq 1 $num_clients); do
  client="client${i}"
  openssl genpkey -algorithm RSA -out ${client}_key.pem
  openssl req -new -key ${client}_key.pem -out ${client}_csr.pem -subj "$subject_base/CN=${client}"
  openssl x509 -req -in ${client}_csr.pem -CA ca_cert.pem -CAkey ca_key.pem -CAcreateserial -out ${client}_cert.pem -days 360 -sha256
done

echo "Certificates generated for client1 to client${num_clients}"

...

Info

Adjust paths, parameters, and configurations as necessary based on your specific environment and requirements.

...