From 96bbd7bf0522a0120805d86c50ab51e0e8078b31 Mon Sep 17 00:00:00 2001 From: Rob Austein Date: Fri, 19 Jan 2007 16:25:24 +0000 Subject: Initial svn path=/scripts/xmlsec-demo.sh; revision=468 --- scripts/xmlsec-demo.sh | 148 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100755 scripts/xmlsec-demo.sh (limited to 'scripts/xmlsec-demo.sh') diff --git a/scripts/xmlsec-demo.sh b/scripts/xmlsec-demo.sh new file mode 100755 index 00000000..9cf6bb9d --- /dev/null +++ b/scripts/xmlsec-demo.sh @@ -0,0 +1,148 @@ +#!/bin/sh - +# $Id$ + +# Demo of how one could use the xmlsec package to sign and verify XML +# messages. On FreeBSD, the xmlsec 1.x command line program is called +# "xmlsec1" to distinuish it from the old xmlsec 0.x program, which +# had a somewhat different command line syntax. YMMV. +# +# Basic idea of the demo is to create a four level deep cert chain, +# use that to sign an XML document, then demonstrate that it verifies. + +set -xe + +: ${input=input.xml} ${unsigned=unsigned.xml} ${signed=signed.xml} +: ${alice=alice} ${bob=bob} ${carol=carol} ${dave=dave} +: ${xmlsec=xmlsec1} + +# Some input with which to work. Feel free to supply your own instead. + +test -r $input || cat >$input <<'EOF' + + + X.509 Extensions for IP Addresses and AS Identifiers + + + + + + + + + + + allocation + atrribute certificate + authorization + autonomous system number authorization + certificate + delegation + internet registry + ip address authorization + public key infrastructure + right-to-use + secure allocation + + This document defines two X.509 v3 certificate extensions. The + first binds a list of IP address blocks, or prefixes, to the + subject of a certificate. The second binds a list of autonomous + system identifiers to the subject of a certificate. These + extensions may be used to convey the authorization of the + subject to use the IP addresses and autonomous system + identifiers contained in the extensions. [STANDARDS TRACK] + + + + + + + + +EOF + +# Set of a simple chain of certs. + +for i in $alice $bob $carol $dave +do + test -r $i.cnf || cat >$i.cnf < + + + + + + + + + + + + + + HjY8ilZAIEM2tBbPn5mYO1ieIX4= + + + + + + + + + + + + + +EOF + +# Sign the template we generated. We sign with the bottommost key, +# and include the two bottommost certs in the signed document. + +test -r $signed || +$xmlsec sign --privkey-pem $dave.key,$dave.cer,$carol.cer --output $signed $unsigned + +# Verify the signed message. We tell xmlsec to trust the root cert, +# and supply the second level cert as it's not in the signed message. +# This should be enough for xmlsec to verify the signature; removing +# any these should cause verification to fail (try it!). + +$xmlsec verify --trusted-pem $alice.cer --untrusted-pem $bob.cer $signed -- cgit v1.2.3