Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Running a bash command for android?

Posted on 2011-03-09
3
Medium Priority
?
1,339 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 2000 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

Industry Leaders: 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

The SignAloud Glove is capable of translating American Sign Language signs into text and audio.
This article will show how Aten was able to supply easy management and control for Artear's video walls and wide range display configurations of their newsroom.
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…
Progress

609 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