#!/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. # Subsequent discussion on the mailing list concluded that xmlsec (the # protocol, not just this particular implementation) is hopelessly # broken and that we should just use CMS (aka PKCS#7 ng). Done. 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 up a simple chain of certs. for i in $alice $bob $carol $dave do test -r $i.cnf || cat >$i.cnf < 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