Solved

Running a bash command for android?

Posted on 2011-03-09
3
1,320 Views
Last Modified: 2012-05-11
Hi,

I need help understanding a bash command (I think) from this article:

  http://blog.crazybob.org/2010/02/android-trusting-ssl-certificates.html#comment-form

"2. Android has built-in support for the Bouncy Castle keystore format (BKS). Put Bouncy Castle's jar in your classpath, and create a keystore containing only your trusted key."

export CLASSPATH=bcprov-jdk16-145.jar
CERTSTORE=res/raw/mystore.bks
if [ -a $CERTSTORE ]; then
    rm $CERTSTORE || exit 1
fi
keytool \
      -import \
      -v \
      -trustcacerts \
      -alias 0 \
      -file <(openssl x509 -in mycert.pem) \
      -keystore $CERTSTORE \
      -storetype BKS \
      -provider org.bouncycastle.jce.provider.BouncyCastleProvider \
      -providerpath /usr/share/java/bcprov.jar \
      -storepass ez24get

I'm not sure how to execute the above. Do I run this in a series of console commands, or do I paste that entire block to a .sh file and try to run it like:

  sh ./thescript.sh

Not sure - I'm also not sure which elements in the above I need to replace. "storepass" probably. I think I can leave everything else as-is?

Thanks
0
Comment
Question by:DJ_AM_Juicebox
  • 2
3 Comments
 
LVL 12

Accepted Solution

by:
Amick earned 500 total points
ID: 35095688
You can run this as a shell script, which seems to be what was intended, or you can run individual commands in sequence.
I agree with your analysis of leaving everything but storepass as-is.
0
 

Author Comment

by:DJ_AM_Juicebox
ID: 35103818
Hmm ok so this is how I modified the script (I saved it to a .sh file):

export CLASSPATH="/Users/me/Desktop/lib/java/bouncycastle/bcprov-jdk16-145.jar"
CERTSTORE=res/raw/mystore.bks
if [ -a $CERTSTORE ]; then
    rm $CERTSTORE || exit 1
fi
keytool \
      -import \
      -v \
      -trustcacerts \
      -alias 0 \
      -file <(openssl x509 -in mycert.pem) \
      -keystore $CERTSTORE \
      -storetype BKS \
      -provider org.bouncycastle.jce.provider.BouncyCastleProvider \
      -providerpath /usr/share/java/bcprov.jar \
      -storepass mypassword

when I try to run it:

./test.sh: line 11: syntax error near unexpected token `('
./test.sh: line 11: `      -file <(openssl x509 -in mycert.pem) \'

Am I supposed to replace the parenthesis with something?

Thanks
0
 
LVL 12

Expert Comment

by:Amick
ID: 35109718
It appears that the script is trying to use the output of the openssl command as input to the keytool "-file" option, so you might try using ` marks rather than parentheses as in
  -file <`openssl x509 -in mycert.pem` \
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Often, people trade privacy and security for convenience. However in today's concrete jungle, this is an extremely foolish decision considering the vast amount of technologies being used against consumer interest. First off, I won't waste any time e…
Once again I push the limits of my phone.  An introduction to the Android Google Now Launcher.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now