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

#### Print out information about a certificate

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 <certificate>" >&2
    exit 1
}

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

cert=${1}

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

# echo $OPENSSL_CONF

doopenssl x509 -in ${cert} -text -nameopt multiline
