]> git.ipfire.org Git - thirdparty/squid.git/blame - helpers/external_acl/kerberos_ldap_group/cert_tool
Boilerplate: update copyright blurbs for Squid tools
[thirdparty/squid.git] / helpers / external_acl / kerberos_ldap_group / cert_tool
CommitLineData
b1218840
AJ
1#!/bin/ksh
2#
3# -----------------------------------------------------------------------------
4#
5# Author: Markus Moeller (markus_moeller at compuserve.com)
6#
7# Copyright (C) 2007 Markus Moeller. All rights reserved.
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation; either version 2 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program; if not, write to the Free Software
21# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22#
23# -----------------------------------------------------------------------------
24#
25#
26# creates the following files:
27# <server>.cert
28# secmod.db
29# key3.db
30# cert8.db
31#
32#
33if [ -z "$1" ]; then
34 echo "Usage: `basename $0` ldap-server port"
35 exit 0
36fi
37if [ -z "$2" ]; then
38 port=636
39else
40 port=$2
41fi
42
43server=$1
44
45#
46# Remove old files
47#
48rm ${server}_[0-9]*.cert 2>/dev/null
49#
50# Get certs and store in .cert file
51#
52( openssl s_client -showcerts -connect $server:$port 2>/dev/null <<!
53QUIT
54!
55) | awk 'BEGIN{start=0;ostart=0}{if ( $0 ~ /BEGIN CERTIFICATE/ ) { start=start+1 };
56 if ( start > ostart ) {print $0 >>"'$server'_"start".cert"};
57 if ( $0 ~ /END CERTIFICATE/) { ostart=start } }'
58
59#
60# from mozilla-nss-tools
61# /usr/sfw/bin on Solaris
62#
63#
64# Create database for Sun ldap and pem file for Openldap
65#
66rm ${server}_[0-9]*.pem 2>/dev/null
67let i=0
68 ls ${server}_[0-9]*.cert | while read file; do
69 let i=i+1
70 cat $file >> ${server}_$i.pem
71 CA=`openssl x509 -noout -text -in ${server}_$i.pem | grep -i "CA:.*true"`
72 if [ -n "$CA" ]; then
73 echo "CA is in ${server}_$i.pem"
74 certutil -A -a -n "${server}_$i" -i $file -t "C,," -d .
75 else
76 certutil -A -a -n "${server}_$i" -i $file -t "P,," -d .
77 fi
78 rm $file
79done
80echo "Certs:"
81certutil -d . -L
82echo "are in"
83ls *.db