Commit a9fbc474 authored by Alain Takoudjou's avatar Alain Takoudjou

check_url_available recipe support certificate and key for client authentication

parent f4e47b9e
...@@ -39,6 +39,9 @@ class Recipe(GenericBaseRecipe): ...@@ -39,6 +39,9 @@ class Recipe(GenericBaseRecipe):
'curl_path': self.options['curl_path'], 'curl_path': self.options['curl_path'],
'check_secure': self.options.get('check-secure', 0), 'check_secure': self.options.get('check-secure', 0),
'http_code': self.options.get('http_code', '200'), 'http_code': self.options.get('http_code', '200'),
'ca-cert-file': self.options.get('ca-cert-file', ''),
'cert-file': self.options.get('cert-file', ''),
'key-file': self.options.get('key-file', ''),
} }
# XXX-Cedric in this script, curl won't check certificate # XXX-Cedric in this script, curl won't check certificate
......
...@@ -3,13 +3,20 @@ ...@@ -3,13 +3,20 @@
# BEWARE: It will be overwritten automatically # BEWARE: It will be overwritten automatically
URL="%(url)s" URL="%(url)s"
CA_CERT="%(ca-cert-file)s"
CERT="%(cert-file)s"
KEY="%(key-file)s"
if [ -z "$URL" ]; then if [ -z "$URL" ]; then
echo "No URL specified." >&2 echo "No URL specified." >&2
exit 3 exit 3
fi fi
CODE=$(%(curl_path)s -g -k -sL $URL -w %%{http_code} --max-time 10 -o /dev/null) if [ -z "$CA_CERT" ] || [ -z "$CERT" ] || [ -z "$KEY" ]; then
CODE=$(%(curl_path)s -g -k -sL $URL -w %%{http_code} --max-time 10 -o /dev/null)
else
CODE=$(%(curl_path)s -g -k -sL $URL -w %%{http_code} --max-time 10 -o /dev/null --cacert $CA_CERT --cert $CERT --key $KEY)
fi
if [ $? -eq 3 ]; then if [ $? -eq 3 ]; then
echo "URL malformed: $URL." >&2 echo "URL malformed: $URL." >&2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment