#! /bin/sh # Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ # self-cert.sh for ejabberd openssl=$(which openssl) [[ -z "${openssl}" ]] && openssl="/usr/bin/openssl" if ! [[ -x "${openssl}" ]]; then echo "openssl required for certificates" >&2 exit 1 fi usage() { local error="$@" [[ -z "${error}" ]] || echo -e "Error: ${error}\n" cat </dev/null fi "${openssl}" req -new -x509 -days 365 -nodes -config "${config}" \ -out "${output}" -keyout "${output}" || \ cleanup "Creating key failed" "${openssl}" gendh -rand "${rnd}" 512 >> "${output}" || \ cleanup "Adding of required extensions failed" "${openssl}" x509 -subject -dates -fingerprint \ -noout -in "${output}" || \ cleanup "Certificating failed" rm -f "${rnd}" exit 0 } main "$@"