#!/bin/sh
. $(dirname $0)/../test_library

start() {
  ../../src/stunnel -fd 0 <<EOT
  debug = debug
  syslog = no
  pid = ${result_path}/stunnel.pid
  output = ${result_path}/stunnel.log

  [https client]
  client = yes
  accept = 127.0.0.1:${http1}
  connect = 127.0.0.1:${https}

  [https server]
  accept = 127.0.0.1:${https}
  connect = 127.0.0.1:${http2}
  cert = ${script_path}/certs/server_cert.p12
EOT
}

check_ports "015_p12_cert"
if grep -q "OpenSSL 1" "results.log"
  then
    start 2> "error.log"
    test_log_for "015_p12_cert" "success" "$1" 2>> "stderr.log"
    exit $?
  else
    exit_logs "015_p12_cert" "skipped"
    exit 125
  fi
