Solved

Running a bash command for android?

Posted on 2011-03-09
3
1,316 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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

If your app took Google’s lash recently, here are the 5 most likely reasons.
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

772 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

11 Experts available now in Live!

Get 1:1 Help Now