Headless HTTPS Usage on Linux

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Headless HTTPS Usage on Linux

Sven Van Caekenberghe
I have the impression that there is still some confusion around using Zodiac to do HTTPS access.

The easiest way to try this for yourself is to download the customized one-click image:

        http://dl.dropbox.com/u/16235440/Pharo-1.3-Zodiac-OneClick.app.zip  (~25Mb)

Now, next is some code that shows how do a command line google search using HTTPS on Linux.

Let's build a curl like tool that can do this:

$ ./query-google.sh 'Pharo Smalltalk' | less

[…]

$ cat query-google.sh

#!/bin/bash
script_home=$(dirname $0)
script_home=$(cd $script_home && pwd)
image=$script_home/experimental.image
script=$script_home/query-google.st
args=$*
vm=$script_home/bin/CogVM
options="-vm-display-null -vm-sound-null"
#echo $vm $options $image $script $args
$vm $options $image $script $args

$ cat query-google.st

| result |
result := ZnClient new
  systemPolicy;
  beOneShot;
  https;
  host: 'encrypted.google.com';
  addPath: 'search';
  queryAt: 'q' put: Smalltalk commandLine arguments first;
  get.
FileStream stdout nextPutAll: result.
Smalltalk quitPrimitive.

$ cat build.st

"Script to update a stock Pharo 1.3 image with application specific code"

Gofer new
  squeaksource: 'ZincHTTPComponents';
  package: 'Zinc-HTTP';
  package: 'Zinc-AWS';
  load.

Gofer new
  squeaksource: 'Zodiac';
  package: 'Zodiac-Core';
  load.

Gofer new
  squeaksource: 'ZincHTTPComponents';
  package: 'Zinc-Zodiac';
  load.

SmalltalkImage current
  saveAs: 'experimental';
  snapshot: false andQuit: true.

Using this VM

        http://gforge.inria.fr/frs/download.php/29042/CogVM-Unix-13307.zip

Add SqueakSSL.so next to your VM

$ ls -la bin
total 1480
drwxr-xr-x 2 ubuntu ubuntu    4096 2012-01-30 15:32 .
drwxr-xr-x 4 ubuntu ubuntu    4096 2012-01-30 15:41 ..
-rwxr-xr-x 1 ubuntu ubuntu 1148103 2011-08-31 12:51 CogVM
-rwxr-xr-x 1 ubuntu ubuntu   63490 2011-08-31 12:51 libB3DAcceleratorPlugin.so
-rwxr-xr-x 1 ubuntu ubuntu   28829 2011-08-31 12:51 libFT2Plugin.so
-rwxr-xr-x 1 ubuntu ubuntu   29708 2011-08-31 12:51 libSqueakFFIPrims.so
-rwxr-xr-x 1 ubuntu ubuntu   67498 2012-01-30 15:31 SqueakSSL.so
-rwxr-xr-x 1 ubuntu ubuntu   10765 2011-08-31 12:51 vm-display-null
-rwxr-xr-x 1 ubuntu ubuntu  109674 2011-08-31 12:51 vm-display-X11
-rwxr-xr-x 1 ubuntu ubuntu   23322 2011-08-31 12:51 vm-sound-ALSA
-rwxr-xr-x 1 ubuntu ubuntu    6221 2011-08-31 12:51 vm-sound-null

And everything should be fine.

Sven