FiloSottile / mkcert

A simple zero-config tool to make locally trusted development certificates with any names you'd like.
https://mkcert.dev
BSD 3-Clause "New" or "Revised" License
48.79k stars 2.52k forks source link

How to change publisher info #245

Open lasyka opened 4 years ago

lasyka commented 4 years ago

The default mkcert commad's cert info is:
Subject: /O=mkcert development certificate/OU=root@myosname Issuer: mkcert root@myosname How can i to chage the root@myosname info to www.myhost.com?

ljluestc commented 9 months ago
#!/bin/bash

# Define the desired CN for the root certificate
custom_cn="www.myhost.com"

# Install mkcert if not already installed
if ! command -v mkcert &> /dev/null; then
  echo "mkcert is not installed. Installing..."
  brew install mkcert  # Assuming you have Homebrew on macOS
fi

mkcert -install
mkcert -key-file rootCA-key.pem -cert-file rootCA.pem "${custom_cn}"

domains=("www.myhost.com" "example.com" "anotherdomain.com")

for domain in "${domains[@]}"; do
  mkcert -key-file "${domain}-key.pem" -cert-file "${domain}-cert.pem" "${domain}"
done

echo "Certificates generated successfully."