[SalesForce] Export a private key associated with a self-signed certificate

As part of our CI/CD with Azure, we were able to successfully authorize an Org using the JWT-Based Flow AS LONG AS we follow the steps here

Every time we refresh our sandboxes, we have to go through the whole process again, which is a bit of a pain.

Question is, do you guys know if I can generate a server.key file (which is requried by the JWT Flow) from a self-signed certificate created within Salesforce, and not openssl?

Thanks.

Best Answer

After you create a self-signed cert in SF, you can export the keypair (private key/public key) as a JKS keystore. You can then extract the private key from the keystore via either keytool (ships with Java runtime) or OpenSSL.