test_windows.in revision 233294
190075Sobrien#!/bin/sh
290075Sobrien#
3132718Skan# Copyright (c) 2007 Kungliga Tekniska H��gskolan
490075Sobrien# (Royal Institute of Technology, Stockholm, Sweden). 
590075Sobrien# All rights reserved. 
690075Sobrien#
790075Sobrien# Redistribution and use in source and binary forms, with or without 
8132718Skan# modification, are permitted provided that the following conditions 
990075Sobrien# are met: 
1090075Sobrien#
1190075Sobrien# 1. Redistributions of source code must retain the above copyright 
1290075Sobrien#    notice, this list of conditions and the following disclaimer. 
1390075Sobrien#
1490075Sobrien# 2. Redistributions in binary form must reproduce the above copyright 
1590075Sobrien#    notice, this list of conditions and the following disclaimer in the 
16132718Skan#    documentation and/or other materials provided with the distribution. 
1790075Sobrien#
1890075Sobrien# 3. Neither the name of the Institute nor the names of its contributors 
1990075Sobrien#    may be used to endorse or promote products derived from this software 
2090075Sobrien#    without specific prior written permission. 
21132718Skan#
2290075Sobrien# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 
2390075Sobrien# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
24169689Skan# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
25169689Skan# ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 
26132718Skan# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 
2790075Sobrien# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 
2890075Sobrien# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
2990075Sobrien# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
3090075Sobrien# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 
3190075Sobrien# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 
32132718Skan# SUCH DAMAGE. 
3390075Sobrien#
3490075Sobrien# $Id$
3590075Sobrien#
3690075Sobrien
3790075Sobriensrcdir="@srcdir@"
3890075Sobrienobjdir="@objdir@"
3990075Sobrien
4090075Sobrienstat="--statistic-file=${objdir}/statfile"
4190075Sobrien
42132718Skanhxtool="${TESTS_ENVIRONMENT} ./hxtool ${stat}"
4390075Sobrien
4490075Sobrienif ${hxtool} info | grep 'rsa: hcrypto null RSA' > /dev/null ; then
4590075Sobrien    exit 77
4690075Sobrienfi
4790075Sobrienif ${hxtool} info | grep 'rand: not available' > /dev/null ; then
4890075Sobrien    exit 77
4990075Sobrienfi
5090075Sobrien
5190075Sobrienecho "Create trust anchor"
52132718Skan${hxtool} issue-certificate \
5390075Sobrien    --self-signed \
5490075Sobrien    --issue-ca \
55132718Skan    --generate-key=rsa \
5690075Sobrien    --subject="CN=Windows-CA,DC=heimdal,DC=pki" \
5790075Sobrien    --lifetime=10years \
5890075Sobrien    --certificate="FILE:wca.pem" || exit 1
5990075Sobrien
6090075Sobrienecho "Create domain controller cert"
6190075Sobrien${hxtool} issue-certificate \
6290075Sobrien    --type="pkinit-kdc" \
6390075Sobrien    --pk-init-principal="krbtgt/HEIMDAL.PKI@HEIMDAL.PKI" \
6490075Sobrien    --hostname=kdc.heimdal.pki \
65132718Skan    --generate-key=rsa \
6690075Sobrien    --subject="CN=kdc.heimdal.pki,dc=heimdal,dc=pki" \
67    --certificate="FILE:wdc.pem" \
68    --domain-controller \
69    --crl-uri="http://www.test.h5l.se/test-hemdal-pki-crl1.crl" \
70    --ca-certificate=FILE:wca.pem || exit 1
71
72
73echo "Create user cert"
74${hxtool} issue-certificate \
75    --type="pkinit-client" \
76    --pk-init-principal="user@HEIMDAL.PKI" \
77    --generate-key=rsa \
78    --subject="CN=User,DC=heimdal,DC=pki" \
79    --ms-upn="user@heimdal.pki" \
80    --crl-uri="http://www.test.h5l.se/test-hemdal-pki-crl1.crl" \
81    --certificate="FILE:wuser.pem" \
82    --ca-certificate=FILE:wca.pem || exit 1
83
84echo "Create crl"
85${hxtool} crl-sign \
86	--crl-file=wcrl.crl \
87	--signer=FILE:wca.pem || exit 1
88
89exit 0
90