add support for generating TLSA records directly from a certificate file
[zonemaker.git] / tlsa
1 #!/bin/bash
2 set -euo pipefail
3 # Usage: ./tlsa <certificate filename>
4 # Generates a TLSA record based on the given certificate's public key.
5
6 echo -n "3 1 1 " # DANE-EE Publickey SHA256
7 openssl x509 -noout -pubkey -in "$1" | openssl rsa -pubin -outform DER 2>/dev/null | sha256sum | cut -d' ' -f 1 | tr 'a-z' 'A-Z'