Paste: verify-cn

Author: crest
Mode: shellscript
Date: Mon, 14 Mar 2011 11:32:19
Plain Text |
#!/bin/sh

EX_USAGE='64'

if [ "${#}" -ne 3 ]; then
	echo "usage: ${0} <allowed-cn> <depth> <x509-line>" >&2
	exit "${EX_USAGE}"
fi

ALLOWED_CN="${1}"
DEPTH="${2}"
X509_LINE="${3}"

if [ "${DEPTH}" -eq 0 ]; then
	PEER_CN=$(echo "${X509_LINE}" | sed 's/.*\/CN=\([^/]*\).*/\1/')
	[ "${PEER_CN}" = "${ALLOWED_CN}" ] || exit 1
fi

exit 0

New Annotation

Summary:
Author:
Mode:
Body: