Follow Below Steps convert PEM file into PFX file, you may Use this tool: https://www.sslshopper.com/ssl-converter.html

- Type of Current Certificate 'Standard PEM'
- Type To Convert To 'PFX/PKCS#12'
- Certificate File to Convert - Add 'cert.crt' or 'cert.pem'
- Add the 'Private Key'
- Chain Certificate File - Add 'CABundle.crt'
- Leave Chain Certificate File 2 blank
- Set a new 'PFX Password'
- Click on 'Convert Certificate'

Using Windows PowerShell

Generate a Self-Signed Certificate + Private Key

1. Generate a Self-Signed Certificate + Private Key

powershell
New-SelfSignedCertificate -DnsName "yourdomain.com" -CertStoreLocation "cert:\LocalMachine\My" -KeyExportPolicy Exportable
  • Export the .key file:

    1. Open certlm.msc (Local Machine Certificates).

    2. Go to Personal → Certificates, right-click your cert → Export.

    3. Select "Yes, export the private key" → Choose .PFX (PKCS#12) format.

    4. Extract the .key file using OpenSSL:

      bash
openssl pkcs12 -in cert.pfx -nocerts -out private.key