# Generate Public Key From Private Key Openssl

- Generate Public Key From Private Key Openssl Software
- Generate Public Key From Private Key Openssl Download

The private key is used to decrypt, and to sign things. You don't use it to encrypt. You use the public key for that. But openssl genrsa will not generate the public key, only the private. To encrypt things, you must first generate the public key (so you have a keypair: private and public). Openssl rsa -in yourdomain.key -outform PEM -pubout -out public.pem. How to Generate & Use Private Keys using OpenSSL's Command Line Tool. These commands generate and use private keys in unencrypted binary (not Base64 “PEM”) PKCS#8 format. The PKCS#8 format is used here because it is the most interoperable format when dealing with software that isn't based on OpenSSL.

## Applicable Products

- NetScaler

### Generate Public Key From Private Key Openssl Software

## Instructions

**Note**: First you will need a linux based operating system that supports openssl command to run the following commands.

### Generate Public Key From Private Key Openssl Download

Extract the key-pair

#openssl pkcs12 -in sample.pfx -nocerts -nodes -out sample.keyGet the Private Key from the key-pair

#openssl rsa -in sample.key -out sample_private.keyGet the Public Key from key pair

#openssl rsa -in sample.key -pubout -out sample_public.keyNeed to do some modification to the private key -> to pkcs8 format

#openssl pkcs8 -topk8 -inform PEM -in sample_private.key -outform PEM -nocrypt

Copy the output and save it as sample_private_pkcs8.keyGet those files

public key: sample_public.key

private key: sample_private_pkcs8.key