When you work with clients that are supplying you with their own secure certificates, they may arrive in different formats that you need to convert, in order to add them to Laravel Forge.
Furthermore, depending on the certificate format, they may be binary files that need to be converted.
For a project I'm working on at the moment, I was provided with a
*.pfx file, that I needed to extract the certificate and private key from, in order to drop in to the Laravel Forge UI.
First of all, I need to extract the key.
openssl pkcs12 -in client-cert.pfx -nocerts -out client.key -nodes
If the certificate has an import password or PEM pass phrase, you will be prompted to enter it.
Next, extract the certificate itself:
openssl pkcs12 -in client-cert.pfx -nokeys -out client.crt
And lastly, remove the passphrase from the private key:
openssl rsa -in client.key -out server.key
You'll then need to copy and paste the private key from the
client.key file into the Forge UI.
Next, copy and paste the certificate from the
client.crt file into the Forge UI. Note: You only need to copy the content between and including the begin / end certificate lines.
-----BEGIN CERTIFICATE----- <!-- The certificate body is here --> -----END CERTIFICATE-----
Tip: On a Mac, you can use
pbcopy, which will place the contents on the clipboard:
cat client.key | pbcopy