I have a script (bat file) I used at my last job to easily create new PFX files from .crt files when we didn't know the password to the old .PFX file.
Here is the script:
REM How to use:
REM 1. Export old cert with private key, remember password.
REM 2. Copy to this directory.
REM 3. Copy new cert to this directory.
REM 4. Fill out the SET variables below.
REM 5. Run this script, enter passwords. newpfx is the re-bundled cert you want to install on webserver.
SET oldpfx=test.pfx
SET newcert=test.crt
SET newpfx=testa.pfx
bin\openssl.exe pkcs12 -in %oldpfx% -nocerts -out key.pem -nodes
bin\openssl.exe pkcs12 -export -out %newpfx% -inkey key.pem -in %newcert%
The issue with the above script is that on the last two lines, I always get "the system cannot find the path specified".
At my current job, I installed openssl via an MSI file to the c:\program files\openssl-win 64 and I place the required certs in the bin directory - that's also where the script is as well - the other directories are: exp, include, lib, & tests. Keep in mind that, that's not where it was installed at my last job, I was running he directory from c:\users\username.
The script never prompts me to enter the passwords either. This occurs whether I open the bat file in cmd prompt or powershell.
Any help would be appreciated.