Cardboard Box

Cardboard Box

A place to store useful snippets of code, links and other such geek stuffs.

Examine x509 Certificate

I've noted uses of the "openssl" command before. Here is another.

A quick way to examine a certificate in plain text.

openssl x509 -text -in cert.pem

Labels: , ,

posted by Don @ 1:12 PM, , link to this post

Convert Seperate Key/Cert Files to PFX

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

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

Labels: , ,

posted by Don @ 11:21 AM, , link to this post

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.  Most people dont even realize the 'tr' command exists on most linux/shell releases.

From UPPER to lower: tr [:upper:] [:lower:]
From lower to UPPER: tr [:lower:] [:upper:]

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

Labels: , ,

posted by Don @ 11:31 AM, , link to this post

Enable Syntax Highlighting In Vim (vi), Mac OSX (Leopard)

To enable the syntax highlight feature of Vim on a Mac OSX (Leopard) system, edit the /usr/share/vim/vimrc file and add the "syntax on" config.

To do this from Terminal.app...

sudo vi /usr/share/vim/vimrc

...add a new config, "syntax on" and then save and close the file.

Labels:

posted by Don @ 10:57 AM, , link to this post

Mac Keyboard Shortcuts For Symbols

Mac OSX keyboard shortcut combinations for many common symbols.
™ (trademark) = Option + 2
£ (pound) = Option + 3
¢ (cent) = Option + 4
∞ (infinity) = Option + 5
§ (section) = Option + 6
¶ (paragraph) = Option + 7
• (dot) = Option + 8
€ (euro) = Shift + Option + 2
° (degree) = Shift + Option + 8
¥ (yen) = Option + y
÷ (division) = Option + /
± (plus/minus) = Option + =
≥ (greater than or equal to) = Option + >
≤ (less than or equal to) = Option + <
√ (square root) = Option + v
π (pi) = Option + p
≈ (approx.) = Option + x
∆ (delta) = Option + j
∑ (sum) = Option + w
Ω (ohm) = Option + z
µ (micro) = Option + m
© (copyright) = Option + g
® (registered) = Option + r
† (dagger) = Option + t

Labels:

posted by Don @ 5:45 PM, , link to this post

Convert PFX to Separate Key/Cert Files

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

To extract the private key...
openssl pkcs12 -in [name.pfx] -nocerts -out [private.key]

To extract the certificate...
openssl pkcs12 -in [name.pfx] -clcerts -nokeys -out [certificate.crt]

To decrypt the private key...
openssl rsa -in [private.key] -out [decrypted.key]

Labels: , ,

posted by Don @ 12:24 PM, , link to this post

Strip Leading Zeros In Shell

Nice trick to strip leading zeros from an IP address at the command line.
(ie 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)}'

Labels: , ,

posted by Don @ 1:46 PM, , link to this post

HTTPS PUT w/Basic Authentication Via Curl

Need to use a secure HTTP PUT over SSL using Basic Auth?
curl -T test.txt -u https://[hostname]/[uri]
Add a -v to see that connection with verbose output.

Labels: , ,

posted by Don @ 10:00 AM, , link to this post

Flush DNS Cache, Mac OSX (Leopard)

As a DNS admin, I frequently need to flush my local DNS cache in order to confirm that a change I made on a DNS server worked.  To do this on a Mac OSX (Leopard), open your Terminal.app and run the following command...
dscacheutil -flushcache

Labels:

posted by Don @ 10:45 AM, , link to this post

Home & End Keys, Mac OSX (Leopard)

Using Terminal.app on Mac OSX (Leopard) to connect to an Linux system and work in Vim is a bit of hassle when it comes to the Home and End keys. To remap these such that the 'End' key will take you to the end of the current line and 'Home' the beginning, remap the keys in Terminal->Preferences->Settings->Keyboard to the following...

End: ctrl + [, [, 4, ~ it should look like this \033[1~
Home: ctrl + [, [, 1, ~ it should look like this \033[4~

This tip and others were found here.

Labels:

posted by Don @ 1:22 PM, , link to this post

About This Blog

This blog is a place where I hope to put the snippets and trimmings of my geek'dom ... code samples that have served me well, tech links and other such things that'll I find useful. In short, any time I have to Google something, I tend to post it here for others to find as well.

Also, having owned 'digital-penguin.com' for many years and having worked with many a fellow geek, this site also serves as a place where I can always be found.


Labels

Previous Posts

Archives

Links

Powered by Blogger