Skip to main content

Gutzi

JeDepending nachon Größethe euressize Heimnetzwerkesof müssenyour diehome Schrittenetwork, the "ZertifikateCreate erstellen"certificates" dauerndsteps abgearbeitethave werden,to wasbe nervigcarried werdeout kann.continuously, Vorwhich allencan Dingenbe wennannoying. manEspecially sichif malyou nachwant einigerto Zeitdecide füron einena neuennew Domänendomain Namenname entscheidenafter will.some time... EsThere gibtare auchalso Geräte,devices, z.B.e.g. AVM Routerrouters oderor Appsapps (z.B.e.g. Plex) diethat akzeptierenonly nuraccept einea .pfx (PKCS#12-Standard)PKCS#12 standard)! Hm, undand schonwe're wärenalready wirout gekniffenof luck  😤 ...

1. allesall in einemone Schritt,step, oups ...Scriptscript

FürFor alleall die,those diewho diehave Realisierungimplemented wiethe vonrealization miras empfohlenrecommended aufby einemme on a PI oderor Linux Gerätdevice, implementierthere haben,is kommta hierscript einthat Script,is dasquickly schnelladapted angepasstand istthen undtakes dannyour euredomain Domäneas alsa Parameterparameter nimmtand undautomatically allecreates erforderlichenall Dateienthe automatischnecessary erstellt.files.

8-tung! DasThe Stammzertifikatroot musscertificate vorhandenmust exist / bereitshave erstelltalready sein!been undcreated! sichand imbe gleichenlocated Verzeichnisin befindenthe wiesame dasdirectory Script.as the script.

#!/bin/bash

#Required
domain=$1
commonname=$domain

#Change to your company details
country=<>
state=<>
locality=<>
organization=<>
organizationalunit=<>
email=<>

if [ -z "$domain" ]
then
    echo "Argument not present."
    echo "Useage $0 [common name]"

    exit 99
fi

echo "1. generating .key for $domain"
#generate a .key
openssl genrsa -out $domain.key 2048
echo "successful!"
echo ""

echo "2. generating .csr for $domain"
#generate a .csr
openssl req -new -key $domain.key -out $domain.csr \
    -subj "/C=$country/ST=$state/L=$locality/O=$organization/OU=$organizationalunit/CN=$commonname/emailAddress=$email"
echo "successful!"
echo ""


echo "3. generating .ext for $domain"
cat > $domain.ext <<EOF
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = $domain

EOF
echo "successful!"
echo ""

echo "4. creating .csr for $domain"
openssl x509 -req -in $domain.csr -CA <SLD>.pem -CAkey <SLD>.key -CAcreateserial -out $domain.crt -days 3650 -sha256 -extfile $domain.ext
echo "successful!"
echo ""

echo "5. creating .pem for $domain"
cat $domain.crt $domain.key > $domain.pem
echo "successful!"
echo ""

echo "6. creating .pfx for $domain"
openssl pkcs12 -export -in $domain.pem -out $domain.pfx
echo "successful!"
echo ""
echo "---------------------------"
echo "-------- All Set! ---------"
echo "---------------------------"
echo
  • HierYou könntcan ihrdownload dasthe Scriptscript herunterladen:here: genCert.zip
  • entpackenand undadapt aufit eureto Bedürfnisseyour anpassenneeds (suchtsearch nachfor <> und nachand <SLD>. DannThen abspeichern.save it.
  • mitmake demthe Kommando:script executable with the command: "sudo chmod +x <scriptname>.sh" ausführbar machen

fertigDONE!!

ausführenExecute mitwith Kommando:command: "./<sriptname>.sh <subDomäne.SLD.TLD>"  🤗