isync

mailbox synchronization program
git clone https://git.code.sf.net/p/isync/isync
Log | Files | Refs | README | LICENSE

commit 4086e9d4fb4021b6436ed5842703c83755651991
parent 089f7c01b82acb176c3ca6620af238de62d3fcd7
Author: Theodore Ts'o <tytso@users.sf.net>
Date:   Thu, 15 Jan 2004 03:51:11 +0000

Script that can be used to extract the server's certificate from an IMAP
server.

Diffstat:
Aget-cert | 42++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+), 0 deletions(-)

diff --git a/get-cert b/get-cert @@ -0,0 +1,42 @@ +#!/bin/sh +# +# This script will extract the necessary certificate from the IMAP server +# It assumes that an attacker isn't trying to spoof you when you connect +# to the IMAP server! You're better off downloading the certificate +# from a trusted source. +# +# Copyright (C) 2003 Theodore Ts'o <tytso@alum.mit.edu> +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# + +HOST=$1 +TMPFILE=/tmp/get-cert.$$ +ERRFILE=/tmp/get-cert-err.$$ +CERTFILE=/tmp/cert.$$ + +echo QUIT | openssl s_client -connect $HOST:993 -showcerts \ + > $TMPFILE 2> $ERRFILE +sed -e '1,/^-----BEGIN CERTIFICATE-----/d' \ + -e '/^-----END CERTIFICATE-----/,$d' < $TMPFILE > $CERTFILE + +if test -s $CERTFILE ; then + echo -----BEGIN CERTIFICATE----- + cat $CERTFILE + echo -----END CERTIFICATE----- +else + echo "Couldn't retrieve certificate. Openssl reported the following errors" + cat $ERRFILE +fi +/bin/rm -f $TMPFILE $ERRFILE $CERTFILE