Wednesday, November 6, 2013

more on certificate administration

bash - how to represent multiple conditions in shell script? - Stack Overflow

http://stackoverflow.com/questions/3826425/how-to-represent-multiple-conditions-in-shell-script

Bash script conditional statements.

OR

if [ $g -eq 1 -a "$c" = "123" ] || [ $g -eq 2 -a "$c" = "456" ]
then echo abc
else echo efg
fi

AND

if [ $g -eq 1 ] && [ "$c" = "123" ]
then echo abc
elif [ $g -eq 2 ] && [ "$c" = "456" ]
then echo abc
else echo efg
fi

Bash Beginner Check Exit Status - Stack Overflow

http://stackoverflow.com/questions/5195607/bash-beginner-check-exit-status

Test in a bash script to see if the last operation had an error. This checks the status code of the last operation.

function test {
    "$@"
    status=$?
    if [ $status -ne 0 ]; then
        echo "error with $1"
    fi
    return $status
}

test command1
test command2

bash script 'for each command line argument'

http://www.linuxquestions.org/questions/linux-newbie-8/bash-script-%27for-each-command-line-argument%27-429058/

Looping over arguments in a bash script call.

    for ARG in "$@"
    do
        echo $ARG
    done

How to slice an array in bash - Stack Overflow

http://stackoverflow.com/questions/1335815/how-to-slice-an-array-in-bash

Slicing an array (like the array of command line arguments) in a bash script.

A=( foo bar "a  b c" 42 )
B=("${A[@]:1:2}")
echo "${B[@]}"    # bar a  b c
echo "${B[1]}"    # a  b c
div[style='display: none;']
ul>li*>a[href=$#]{$#}; li*>a[href=$#]{$#}

Creating Your Own SSL Certificate Authority (and Dumping Self Signed Certs) | The Data Center Overlords

http://datacenteroverlords.com/2012/03/01/creating-your-own-ssl-certificate-authority/

Signing a csr using a root authority. For testing purposes, this is an easy way to sign a certificate from the comfort of your own workstation.

openssl x509 -req -in device.csr -CA root.pem -CAkey root.key -CAcreateserial -out device.crt -days 500

The Most Common Java Keytool Keystore Commands

http://www.sslshopper.com/article-most-common-java-keytool-keystore-commands.html

This is a great resource for many common keytool commands. In particular, I was trying to remember how to delete a key from a keystore.

keytool -delete -alias mydomain -keystore keystore.jks

Cunning: Importing private keys into a Java keystore using keytool

http://cunning.sharp.fm/2008/06/importing_private_keys_into_a.html

Entry description

keytool -importkeystore -deststorepass changeit -destkeypass changeit -destkeystore my-keystore.jks -srckeystore cert-and-key.p12 -srcstoretype PKCS12 -srcstorepass cert-and-key-password -alias 1

The alias of 1 is required to choose the certificate in the source PKCS12 file, keytool isn't clever enough to figure out which certificate you want in a store containing one certificate. - Graham Leggett

http://cunning.sharp.fm/2008/06/importing_private_keys_into_a.html

CTX106630 - How to Use OpenSSL to Create PKCS#12 Certificate Files - Citrix Knowledge Center

http://support.citrix.com/article/CTX106630

Export a PKCS12 keystore from a java keystore. PKCS12 are nice for bundling a certificate chain with your private key and then importing back into your java keystore.

openssl pkcs12 -export -in input.crt -inkey input.key -out bundle.p12

openssl - How can I create a Certificate Service Request (CSR) from and existing public key of a key pair (assume the private key is in a safe spot elsewhere)? - Stack Overflow

http://stackoverflow.com/questions/14617306/how-can-i-create-a-certificate-service-request-csr-from-and-existing-public-ke

Creating a CSR from an existing private key.

openssl req -key my.key -out my.csr

You don't create it ever from a public key. Better yet, if you have a java keystore file that the private key came from, just export a public key from the java keystore instead. It might save a little grief.

keytool -export -alias mydomain -file mydomain.crt -keystore keystore.jks

maven 2 - Can I change the alias of my key? - Stack Overflow

http://stackoverflow.com/questions/3483121/can-i-change-the-alias-of-my-key

Change the alias for an existing entry. There is also code to clone a key, but I didn't need it at the time.

keytool -changealias -alias "your-very-very-long-alias" -destalias "new-alias" -keypass keypass -keystore /path/to/keystore -storepass storepass

No comments:

Post a Comment