1
0
Fork 0

use Net::DNS

This commit is contained in:
Florian Obser 2017-04-23 09:28:03 +02:00
parent 6ea7b77093
commit b699bf6311
1 changed files with 8 additions and 5 deletions

View File

@ -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;
}