Examine x509 Certificate

A quick way to examine a certificate in plain text…

openssl x509 -text -in cert.pem

Convert Separate Key/Cert Files to a PFX

The reverse of the process of extracting the key/certs from a PFX can be achieved via…

openssl pkcs12 -export -in [certificate.crt] -inkey [private.key] -out [package.pfx]

Upper To Lower To Upper Case Command Line

Nice trick to pipe command line data through to convert it’s alpha characters to upper or lower case.

From UPPER to lower…

tr [:upper:][:lower:]

From lower to UPPER…

tr [:lower:][:upper:]

For example…

ls /directory | tr [:lower:][:upper:] | sort

Mount ISO (.iso) In Linux

To mount an ISO (.iso) on a Linux system…

mount -t iso9660 -o ro,loop /path/to/file.iso /path/to/mount/point

In many cases you will not have to specify the “-t iso9660” as most Linux distributions will auto detect that.  The “ro” in the “-o ro,loop” tells this system to mount the .iso read only.

Strip Leading Zeros In Shell

Nice trick to strip leading zeros from an IP address at the command line (it turn 002.203.017.001 to 2.203.17.1)…

echo 002.203.017.001 | awk -F “.” ‘{print int($1)”.”int($2)”.”int($3)”.”int($4)}’

Convert PFX to Seperate Key/Cert Files

Using openssl to extract key and certificate files from a .pfx

To extract the private key…

openssl pkcs12 -in [filename.pfx] -nocerts -out [private.key]

To extract the certificate…

openssl pkcs12 -in [filename.pfx] -clcerts -nokeys -out [certificate.crt]

To decrypt the private key…

openssl rsa -in [private.key] -out [decrypted.key]

HTTP(S) PUT w/Basic Authentiation via Curl

Need to use a secure HTTP PUT over SSL using Basic Auth?

curl -T file.txt -u https://[hostname]/[uri]

Add a -v to see that connection with verbose output.