Sometime you need to use an existing certificate and private key pair, stored in a Java keystore file, for a use that requires a PEM formated certificate. For example PEM certificates are needed to create a Dedicated Load Balancer.
First you'll need to export the pair to a PKCS12 file. You can do that with the keytool utility provided by the JDK:
$ keytool -importkeystore -srckeystore keystore.jks -destkeystore exported.p12 -deststoretype PKCS12
Then we can use OpenSSL to extract the public certificate and the private key to individual files, in PEM format. If OpenSSL is not installed, you'll need to use an appropriate method to install it in your system.
$ openssl pkcs12 -nokeys -in exported.p12 -out publicCert.pem $ openssl pkcs12 -nocerts -nodes -in exported.p12 -out secret.key
If you want to use the certificate and key to create a Dedicated Load Balancer you'll need to remove the extra lines above the '-----BEGIN CERTIFICATE-----' line in both files. After that you use the files with the Anypoint CLI tool:
$ anypoint-cli cloudhub load-balancer create myVPC myLB publicCert.pem secret.key
001114824

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.