From b699bf6311c759a17a0b03a0991e73fe13a5c79d Mon Sep 17 00:00:00 2001 From: Florian Obser Date: Sun, 23 Apr 2017 09:28:03 +0200 Subject: [PATCH] use Net::DNS --- gen_tlsa.pl | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/gen_tlsa.pl b/gen_tlsa.pl index d3781d4..9640eee 100755 --- a/gen_tlsa.pl +++ b/gen_tlsa.pl @@ -6,7 +6,7 @@ use autodie; use Digest::SHA; use MIME::Base64; - +use Net::DNS; use constant WAIT_BEGIN => 1; use constant WAIT_END =>2; @@ -18,13 +18,15 @@ sub usage { usage() if (scalar(@ARGV) != 2); -gen_tlsa(@ARGV); +my $tlsa = gen_tlsa(@ARGV); + +say $tlsa->string(); sub gen_tlsa { my ($label, $cert_file) = @_; my $state = WAIT_BEGIN; my $pem = ''; - my ($fh, $line); + my ($fh, $line, $rr); open($fh, '<', $cert_file); while($line = <$fh>) { @@ -41,6 +43,7 @@ sub gen_tlsa { } } close($fh); - say($label, ' IN TLSA 1 0 1 ', - Digest::SHA::sha256_hex(decode_base64($pem))); + $rr = new Net::DNS::RR($label.' IN TLSA 1 0 1 '. + Digest::SHA::sha256_hex(decode_base64($pem))); + return $rr; }