#!/usr/bin/bash

if (( $# == 1)) ; then
CHALLENGE=$(/lib/cryptobone/bin/cltls -silent -stdout GET $1 /cgi-bin/safewebdropregistration?test\&REGISTRATION 2> /dev/null)
    if (( ${#CHALLENGE} == 64 )) ; then
         echo -n "CONNECTED"
	 exit 0
    else
         RET=$(/lib/cryptobone/bin/cltls GET $1 /cgi-bin/safewebdropregisration?test)
         # generate exactly one line as a response
	 LINE=$(echo "${RET}" | /usr/bin/tr '\n' ' ')
         echo -n "FAILED ${LINE}"
         exit 1
    fi
else
    echo "usage: connect_server www.example.com"
    exit 2
fi
