Solved

Running a bash command for android?

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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…
This video is in connection to the article "The case of a missing mobile phone (https://www.experts-exchange.com/articles/28474/The-Case-of-a-Missing-Mobile-Phone.html)". It will help one to understand clearly the steps to track a lost android phone.

816 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

8 Experts available now in Live!

Get 1:1 Help Now