#! /bin/bash
#set -xv
#=========================================================================
# Copyright (C) GemTalk Systems 1986-2024.  All Rights Reserved..
#
# Name - readcsr
# Installed as - readcsr
#
# Written By: Martin McClure and Norm Green
#
# Purpose - Display contents of a certificate signing request (CSR)
#
# Requirements -
#
# The following environment variables must be defined:
#
# GEMSTONE - The root GemStone product tree
#
#=========================================================================

#### Print out information about a certificate signing request

cmd=`basename $0`

# 47501 - handle symlinks
fullPath=`readlink -e -n $0`
scriptDir=`dirname $fullPath`
if [ ! -f $scriptDir/environment.sh ]; then
    echo "[Error]: Cannot find environment.sh setup script"
    exit 1
fi
. ${scriptDir}/environment.sh

usage(){
    echo "Usage: $cmd <csr>" >&2
    exit 1
}

if [ "$1" = "" ]; then
    usage
fi

csr=${1}

if [ ! -f "$csr" ]; then
    echo "[Error]: Cannot open CSR file $csr" >&2
    exit 1
fi

doopenssl req -config ${configDir}/openssl.conf -in ${csr} -text -nameopt multiline
