script extract certificat.pfx

#!/bin/bash

# mettre son fichier pfx
read -p "Entre le chemin de ton fichier PFX : " pfx_file

if [ -f "$pfx_file" ]; then
  echo "le fichier pfx na pas été trouver"
  exit 1
fi

# mettre le nom du certificat a extraire
read -p "Entre le nom du certificat : " cert_name

# extrait la clé privée
openssl pkcs12 in "$pfx_file" -nocerts -out "${cert_name}-encrypted.key"
openssl rsa in "${cert_name}-encrypted.key" -out "${cert_name}.key"

# extrait le certificat
openssl pkcs12 in "$pfx_file" clcerts nokeys out "${cert_name}.crt"

# extrait le CA
openssl pkcs12 in "$pfx_file" -nokeys nodes cacerts -out "${cert_name}-ca.crt"

Revision #3
Created 19 November 2024 10:39:49
Updated 20 January 2025 14:49:17 by Cavallone