Skip to content

Instantly share code, notes, and snippets.

@yalattas
Created March 21, 2023 11:45
Show Gist options
  • Save yalattas/fc2d1e2af46b7732a96755c029bd523f to your computer and use it in GitHub Desktop.
Save yalattas/fc2d1e2af46b7732a96755c029bd523f to your computer and use it in GitHub Desktop.

openssl

establish secure connection using Curl

  1. fetch public certificate to a website
openssl s_client -connect example.com:443 -showcerts </dev/null 2>/dev/null | openssl x509 -outform PEM > ca.crt
  1. generate self-signed certificate
openssl req -newkey rsa:2048 -nodes -keyout client.key -x509 -days 365 -out client.crt
  1. use secure cUrl
curl --cacert /path/to/ca.crt --cert /path/to/client.crt --key /path/to/client.key https://example.com/api

openssl commands

Check a Certificate Signing Request (CSR)

openssl req -text -noout -verify -in CSR.csr

Check a private key

openssl rsa -in privateKey.key -check

Check a certificate

openssl x509 -in certificate.crt -text -noout

Check a PKCS#12 file (.pfx or .p12)

openssl pkcs12 -info -in keyStore.p12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment