On Sat, Dec 14, 2013 at 12:44:49PM -0500, John Allen wrote:

> >>Just a thought, maybe there is a more appropriate forum/mail list to
> >>discuss this on, as this is not strictly Postfix related?
> >
> >It is fine to ask here, Postfix is the first real application to
> >support DANE TLSA.
>
> Thanks for the example I will run it against my own domains. That
> and head over to the sites suggested by Wietse Venema.

Well, you're unlikely to have working TLSA RRs for your SMTP service
just by happenstance.  If you want to create a TLSA RRset for your
SMTP server, run the attached "tlsagen" shell script as follows:

    $ tlsagen cert.pem $(uname -n) DANE-EE PKEY SHA2-256
    _25._tcp.mail.example.com IN TLSA 3 1 1 {hex string}

where "cert.pem" is the file with your Postfix SMTP server certificate,
and $(uname -n) is presumably the fully-qualified domain name of
the server as an MX host for your domain (otherwise use the actual name).

The shell script expects OpenSSL 1.0.0 or later, and will not work
with earlier versions.

Then add the generated RR to your DNS zone file.  When rotating
keys (replacing your private key and cert) publish both the new
and old TLSA records in DNS well before deploying the new key
(allowing the old key to expire from client caches), then deploy
the new key/cert on the server.  Once the server is using the new
key, you can update the DNS again to remove the old key from the
TLSA RRset.

The "posttls-finger" utility included with Postfix 2.11 snapshot
source code can verify DANE SMTP support for your domain:

        $ posttls-finger your-domain.example

If your domain is "klam.ca", then it is not currently verifiable
via DNSSEC because there are no associated DS or DNSKEY RRs in the
"ca." parent zone.  You'd have to get that taken care of via your
registrar before you expend further effort on DANE.  Of course you
need to be sure that your zone signing automation is all in order
first.

-- 
        Viktor.
#! /bin/sh

extract() {
  case "$4" in
  0) openssl x509 -in "$1" -outform DER;;
  1) openssl x509 -in "$1" -noout -pubkey | openssl pkey -pubin -outform DER;;
  esac
}
digest() {
  case "$5" in
  0) cat;;
  1) openssl dgst -sha256 -binary;;
  2) openssl dgst -sha512 -binary;;
  esac
}
encode() {
  perl -e '
    ($cert, $hostport, $u, $s, $m) = @ARGV;
    ($host, $port) = split(":", $hostport); $port ||= 25;
    $/=undef;
    ($a=<STDIN>) =~ s/(.)/sprintf("%02X", ord($1))/egs;
    printf "_%d._tcp.%s. IN TLSA %d %d %d %s\n",
      $port, $host, $usage, $s, $m, $a;
  ' "$@"
}

error() { echo "$1" 1>&2; exit 1; }
usage() { error "Usage: $0 cert.pem host[:port] usage selector mtype"; }
if [ $# -ne 5 ]; then usage; fi

case "$(echo $3 | tr '[A-Z]' '[a-z]')" in
0|pkix-[ct]a)   usage=0;;
1|pkix-ee)      usage=1;;
2|dane-[ct]a)   usage=2;;
3|dane-ee)      usage=3;;
*)              error "Invalid certificate usage: $3";;
esac

case "$(echo $4 | tr '[A-Z]' '[a-z]')" in
0|cert)         selector=0;;
1|spki|pkey)    selector=1;;
*)              error "Invalid selector: $4";;
esac

case "$(echo $5 | tr '[A-Z]' '[a-z]')" in
0|full)                         mtype=0;;
1|sha2-256|sha256|sha-256)      mtype=1;;
2|sha2-512|sha512|sha-512)      mtype=2;;
*)                              error "Invalid matching type: $5";;
esac

set -- "$1" "$2" "$usage" "$selector" "$mtype"
extract "$@" | digest "$@" | encode "$@"

Reply via email to