Skip to content

Instantly share code, notes, and snippets.

@realduke2000
Created June 27, 2018 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realduke2000/b17c00e20ab061be947e03481a26c224 to your computer and use it in GitHub Desktop.
Save realduke2000/b17c00e20ab061be947e03481a26c224 to your computer and use it in GitHub Desktop.
#!/bin/bash
# https://raymii.org/s/tutorials/Encrypt_and_decrypt_files_to_public_keys_via_the_OpenSSL_Command_Line.html
# Get the public key
openssl rsa -in certificate.pem -out publickey.pem -outform PEM -pubout
# Generate the random password file
openssl rand -base64 128 -out key.bin
# Encrypt the random key with the public keyfile
openssl rsautl -encrypt -inkey publickey.pem -pubin -in key.bin -out key.bin.enc
# Decrypt the random key with our private key file
openssl rsautl -decrypt -inkey privatekey.pem -in key.bin.enc -out key.bin
# Get private key
openssl rsa -check -in authservice-ca.key.pem
# View cert
openssl rsa -in authservice-ca.key.pem -check
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment