Update fzf location
[dotfiles] / .bash_openssl
1 #!/bin/sh
2
3 function openssl-view-certificate () {
4 openssl x509 -text -noout -in "${1}"
5 }
6
7 function openssl-view-csr () {
8 openssl req -text -noout -verify -in "${1}"
9 }
10
11 function openssl-view-key () {
12 openssl rsa -check -in "${1}"
13 }
14
15 function openssl-view-pkcs12 () {
16 openssl pkcs12 -info -in "${1}"
17 }
18
19 # Connecting to a server (Ctrl C exits)
20 function openssl-client () {
21 openssl s_client -status -connect "${1}":443
22 }
23
24 # Convert PEM private key, PEM certificate and PEM CA certificate (used by nginx, Apache, and other openssl apps) to a PKCS12 file (typically for use with Windows or Tomcat)
25 function openssl-convert-pem-to-p12 () {
26 openssl pkcs12 -export -inkey "${1}" -in "${2}" -certfile ${3} -out ${4}
27 }
28
29 # Convert a PKCS12 file to PEM
30 function openssl-convert-p12-to-pem () {
31 openssl pkcs12 -nodes -in "${1}" -out "${2}"
32 }
33
34 # Check the modulus of a certificate (to see if it matches a key)
35 function openssl-check-certificate-modulus {
36 openssl x509 -noout -modulus -in "${1}" | shasum -a 256
37 }
38
39 # Check the modulus of a key (to see if it matches a certificate)
40 function openssl-check-key-modulus {
41 openssl rsa -noout -modulus -in "${1}" | shasum -a 256
42 }
43
44 # Check the modulus of a certificate request
45 function openssl-check-key-modulus {
46 openssl req -noout -modulus -in "${1}" | shasum -a 256
47 }
48
49 # Encrypt a file (because zip crypto isn't secure)
50 function openssl-encrypt () {
51 openssl aes-256-cbc -in "${1}" -out "${2}"
52 }
53
54 # Decrypt a file
55 function openssl-decrypt () {
56 openssl aes-256-cbc -d -in "${1}" -out "${2}"
57 }