Solved

Running a bash command for android?

Posted on 2011-03-09
3
1,329 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Restore Windows 7 Snipping Tool function to Windows 10 10 94
Active Directory Account getting mysteriously locked 13 80
AvlTree-Node Data type 4 27
Survey branching tutorial 11 44
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Here, we have shared an easy step by step tutorial on how to download instagram images and videos on PC, Android Mobile and iOS mobile.
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 …
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

726 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