Thank you very much again for very valuable and all help. "tlsagen" is fantastic bash script (it uses openssl and perl). (But, i could not utilize SPKI C_A_D gen functions in my side).
D-O = Domain-Owner. ZO = Zone-Operator.
Few/Other helpful instructions for D-O / ZO :
Convert a .pem based SSL / TLS certificate (use public-portion only)
file, into its equivalent binary DER based cert file:
openssl x509 -in SSL-cert-file.pub.pem \
-outform DER \
-out SSL-cert-file.pub.der
If you are sure your .pem file is actually & really in PEM format,
then you can add this portion in above command: -inform PEM
(From openssl.org site : "If no nameopt switch is present the
default "oneline" format is used...". "oneline : ... It is
equivalent to specifying the esc_2253, esc_ctrl, esc_msb, utf8,
dump_nostr, dump_der, use_quote, sep_comma_plus_space, space_eq and
sname options). (So using "-nameopt oneline" is not necessary).
Always use only public-portion of a SSL/TLS certificate, when
creating C_A_D codes for TLSA dns RRs. Do not keep or use
private_key portion inside your .pem or .cer or .crt cert file, when
you will use it for creating C_A_D. Many users forget to remove
private_key portion from pem file, so be careful about that.
C_A_D = Certificate Association Data. Used in TLSA dns record (RR),
obtained/created from or based on, a SSL/TLS certificate.
Command-lines in linux/unix can be joined using "&&" symbols (use
without double-quotes). Shown "\" (backslash) symbol is just an
indicator that next line is part of this line. So in your actual
command-line, do not use those "\" symbols, instead join them, to
form one single long command-line. In this email we use/used it, to
place rest of the command-line in a next line, (as email and
email-reply breaks full lines and words into smaller portions, and
may result into wrong command).
Few other alternative simple commands to convert a DER based full
(public-side) certificate, into full C_A_D, to use in TLSA RRs:
cat SSL-cert-file.pub.der | \
hexdump -v -e '"" 1/1 "%02X" ""' ; echo
(You may see reference [1] in below for how this command was
formed/formulated)
To save the shown C_A_D hexadecimal codes in a file, (so that you
can copy-paste into a zone-file), a ZO/D-O user can do such as this
command-line:
cat SSL-cert-file.pub.der | \
hexdump -v -e '"" 1/1 "%02X" ""' > \
SSL-cert-file.full-cad.tlsa
Another alternative:
openssl x509 -in SSL-cert-file.pub.pem \
-outform DER -nameopt oneline | \
hexdump -v -e '"" 1/1 "%02X" ""' > \
SSL-cert-file.full-cad.tlsa
To append a NL (new-line) or LF (aka, line-feed, aka, "\n")
character at end of long hexadecimal code in a file, such command
can be used:
echo >> SSL-cert-file.full-cad.tlsa
Note: in above, you must use two ">" symbol, for "append" process to
work, like this: >>
All these commands can be joined & applied using one long
command-line, in a bash shell, like this:
openssl x509 -in SSL-cert-file.pub.crt \
-outform DER | hexdump -v -e \
'"" 1/1 "%02X" ""' > \
SSL-cert-file.full-cad.tlsa ; \
echo >> SSL-cert-file.full-cad.tlsa
Another alternative of above command-line, will work in linux/unix
bash shell/terminal like this:
{ openssl x509 -in SSL-cert-file.pub.crt \
-outform DER | \
hexdump -v -e '"" 1/1 "%02X" ""' \
;echo; } > SSL-cert-file.full-cad.tlsa
(You may see reference [3] in below for how this command was
formed/formulated)
To view "SSL-cert-file.full-cad.tlsa" file's content on screen, use
this command:
cat SSL-cert-file.full-cad.tlsa
Another perl based command, to convert a DER based SSL/TLS cert
file, into its equivalent Full C_A_D hexadecimal codes:
perl -e ' $der2cad = ""; $ssl_der_file="";
$ssl_der_file = $ARGV[0]; die
"SSL DER 2 TLSA CAD: Please specify a DER "
."based SSL filename in commandline.\n"
unless $ssl_der_file; open my $fh, "<",
$ssl_der_file or die
"Could not open \"$ssl_der_file\": $!\n"; {
local $/; $der2cad = <$fh>; } close $fh;
$der2cad =~ s/(.)/sprintf("%02X", ord($1))/egs;
printf "$der2cad\n"; ' "SSL-cert-file.pub.der"
Optionally, you should join above 10 lines into one single long one
command line, before executing.
(You may see reference [2] in below for how this command was
formed/formulated)
In above perl codes, it takes each DER binary (bin) character (char)
(from DER file) one by one, ("ord") converts one bin char into
equivalent ASCII numeric, ("ord" can handle Unicode chars), and then
("%X" formatting flag in "sprintf") again converts that into
equivalent Hexadecimal number, and then a formatting is done: if an
ASCII numeric is converted into a hex number which have single
hex-digit then one zero is added in front of it, (if hex conversion
have no hex-digit then upto two zeros will be used as replacement,
but this does not happen as perl "ord" sends at-least one zero),
and, if converted hex have two hex-digits then it remains intact,
and finally this (hex-converted & formatted) number is used to
replace the input bin-char, and in this way one by one, all bin-char
is converted into equivalent hexadecimals.
Even another perl script to convert a DER based SSL cert into its
equivalent Full C_A_D and HASH-256 and HASH-512 hexadecimal codes:
perl -e ' use Digest::SHA qw(sha256_hex sha512_hex);
$rFN = ""; $rFN = $ARGV[0];
$m = " v1.0.201307030000. Bright Star \(bry "
."8 st ar \@a.t\@ ya hoo d.o.t c om\)\n"; die
"SSL DER 2 TLSA CAD\: Specify a DER based SSL "
."filename in commandline.\n$m" unless $rFN; printf
"SSL DER 2 TLSA CAD:\n$m\nAttempting to load "
."\"$rFN\" file..."; open my $rFH, "<", $rFN or die
" Failed To Load $rFN File For Reading: $!\n";
{ local $/; $der = <$rFH>; } close $rFH || warn
" Failed To Close $rFN File: $!\n"; printf
" loading done.\n\n"; $full_cad = $der;
$full_cad =~ s/(.)/sprintf("%02X", ord($1))/egs;
$m = "\; a DNSSEC DANE/TLSA DNS record syntax\:\n"
."\; _port._proto.[host.]domain.TLD. [TTL] IN "
."TLSA u s m C_A_D\n\n\; Replace below \"u\" based "
."on SSL certificate \"usage\"\n\; type, mentioned "
."in\:\n\; "
."https\://tools.ietf.org/html/rfc6698\n\n\; "
."A Full C_A_D hexadecimal code of Full SSL "
."cert\:\n\n_443._tcp.www\.example\.com. 900 IN "
."TLSA u 0 0 $full_cad\n\n";
my $sha = Digest::SHA->new(256); $sha->addfile($rFN, "b");
$sha256 = uc $sha->hexdigest;
$m .= "\; SHA-256 based C_A_D of Full SSL cert\:\n"
."\n_443._tcp.www\.example\.com. 900 IN TLSA u "
."0 1 $sha256\n\n";
$sha = Digest::SHA->reset(512); $sha->addfile($rFN, "b");
$sha512 = uc $sha->hexdigest;
$m .= "\; SHA-512 based C_A_D of Full SSL cert\:\n"
."\n_443._tcp.www\.example\.com. 900 IN TLSA u "
."0 2 $sha512\n\n"; printf "$m";
$wFN = $rFN . ".cad.tlsa"; printf
"Attempting to create or over-write \"$wFN\"...";
open my $wFH, ">", $wFN or die
" Could Not Create or OverWrite $wFN File For "
."Writing: $!\n";
{ print $wFH "$m"; } close($wFH) || warn
" Failed To Close $wFN File: $!\n";
printf " file created.\n"; ' "SSL-cert-file.pub.der"
Above codes are attached as "der2tlsa_pl" file.
Rename der2tlsa_pl, into der2tlsa.pl before using.
A perl command can be:
./der2cad.pl SSL-cert-file.pub.der
(You may see reference [4] in below for how this command was
formed/formulated)
In later version i may add further features.
Perl usually exist in most variants of Linux, Unix, MacOSX type of OSes.
There are Strawberry perl, Active Perl, etc software for Windows OS.
Install and place perl's "bin" folder in your (Windows) OS's PATH
environment variable, and then, either restart computer, or,
logout+login.
Another option for Windows OS users is to get Cygwin's setup file,
and install cygwin and related tools. It can enable you to use
Linux/Unix "bash" or other shell/terminal/console interface, and
cygwin will also enable you to use (various) other software and
tools like : perl, python, gcc, gpg, bind, bind-utils, dig, openssl,
ssh, certtool, danetool, dnssec-keygen, dnssec-dsfromkey,
dnssec-signzone, dnssec-revoke, named-checkzone, gnutls-serv,
gnutls-cli, various types of compilers, ... etc.
For cygwin users only : Inside Cygwin setup do these : for "hexdump"
to work, search for "util-linux" > "Utils" or "System" > select
"util-linux". Also load these : search for "openssl" > Net > select
"openssl", search for "perl" > Interpreters > select "perl", search
for "python" > Interpreters > select "python", search for "bind" >
Net > select "bind-utils" and "bind", search for "openssh" > Net >
select "openssh", search for "gnupg" > Utils > select "gnupg" (GPG).
And complete installation of those (and related components).
Those who (wants to or do) use proxy : Cygwin will allow HTTP proxy.
Though support of Socks5 proxy would have been better. Update
base/cygwin/core (and security related) components via direct
connection. Then smaller or other tools can be updated/loaded via
proxy connection. If your HTTP-proxy is connected to a Socks5
proxy, then make sure to use and configure such HTTP-proxy software,
which will not leak DNS via direct connection. In such case, all DNS
suppose to go through Socks5 proxy tunnel.
It would have been better if cygwin website was DNSSEC signed, (at
the time of writing this, :( it is not signed), and, if their
SSL/TLS certificate was declared in their TLSA/DANE dns record, and
if there was an option to download the "setup.exe" file from a HTTPS
based webpage (or if "setup.exe" was GPG signed and they were
showing asc/sig, but, that is not the case :( at the time of writing
this).
( And it would have been better if "setup.exe" was using (or
obtaining) at-least GPG authenticated file-list & mirror-list, and
was also using at-least gpg authenticated developer-list, where each
developer's package signing keys were pre-declared, so that files
downloaded over non-encrypted connections like HTTP or FTP or when
obtained via proxy, can still be verified authentically in client
side, with (almost) no chance of using a fake file, if a fake or
altered file was delivered to the client side ) <-- Cygwin probably
already doing such, i'm not sure though.
Something similar like above, should be applied on CPAN, Ruby/gems,
etc and similar type of other package management software/tools.
Package management software/tools should be able to handle DNSSEC
queries and responses, on its own.
Specially any software developers or developer-groups who owns
domains/zones, they must declare their package signing GPG KEYS
(public side portion), in their CERT PGP, etc DNS records. They must
declare their web-server's SSL cert's Full C_A_D (or SHA-512 hash
based C_A_D) in their TLSA DNS records. These standards are already
released for some time by now, they should have done it by now.
A DNSSEC signed zone and which also declares SSL cert's TLSA dns
record, indicates that it's owners/developers care about security
and safety of files and user's/people's data/content, and also
indicates that they care about their own security and safety.
And ISC DLV can be used to publish/declare a domain's/zone's DNSSEC
DS keys (public-side), when a domain-name owner or zone-operator do
not yet have full DNSSEC support in their own zone's/domain-name's
registry/registrar or dns/zone-operator company/entity. And in such
case they can instruct users/visitors in their homepage, to also use
ISC DLV dnssec key and enable it in user-side (or visitor/client
-side) local DNS-Server or DNS-Resolver, for DNSSEC (and related)
authentications. They(D-O/ZO) can also use/configure their own DLV
server. Until, a full DNSSEC support is introduced/deployed by
their domain-name's/zone's registry/registrar entities.
And all users, visitors, or clients etc, need to make sure that they
are always using the last & valid & default DNSSEC root-key file or
codes, in their own DNS-Server or DNS-Resolver software. Default
dnssec rootkey comes from Root servers, and these servers are
governed by ICANN/IANA.
I tested each command-lines, scripts posted in this email.
Please do correct mistakes, Thanks in advance,
-- Bright Star.
References/Notes section:
[1] User "grimeton"/"ruth" (in #openssl in Freenode) suggested to use
"cat somecert.der | hexdump", which i had to modify a lot for it to
work. User "damncool" in CommandLineFu.com site showed this
"$hexdump -v -e '"\\""x" 1/1 "%02x" ""' <bin_file>" code, which was
modified further (by me) to show suitable code for C_A_D.
man hexdump
[2] Base code was obtained from
http://perldoc.perl.org/perlvar.html and
And "sprintf("%02x", ord($var))" portion can be seen in this
BinToHexView function
http://php.net/manual/de/function.sprintf.php
And Viktor Dukhovni used this in perl and attached a script file.
[3] It is based on GreyCat's/Greg's Wiki:
http://mywiki.wooledge.org/BashGuide
http://bash.cumulonim.biz/
[4] PDPC supporter/user "tm604"/"tom" (in #perl at Freenode IRC)
contributed perl codes related to calculating SHA-256, i added
SHA-512 into it based on below site, and added other codes.
https://metacpan.org/module/Digest::SHA
Received from Viktor Dukhovni, on 2013-06-17 1:16 AM:
> On Sun, Jun 16, 2013 at 11:03:48PM -0700, Bry8 Star wrote:
>
>> how you can make direction easy for such vast groups of users.
>
> A fair question.
>
> I won't attempt to explain how to operate a DNSSEC signed zone
> here, sadly this is still rather complex, since DNSSEC signed zones
> need to be frequently and automatically resigned, and rotating the
> KSK DS records in registries is harder still. If that's part of
> your question, perhaps someone else is willing to tackle this rather
> weighty topic, maybe on a DNSSEC list, if not here.
>
> So let's assume that you've somehow crossed the hurdle of implementing
> DNSSEC.
>
> Let's also assume that you have some TLS-enabled service on TCP
> port 12345 of host mumble.example.com and you want to publish DANE
> TLSA records for this host.
>
> The certificate association portion of a TLSA record contains binary
> data that is usually presented in hexadecimal form for ease of
> entry into zone files. The underlying binary data is either:
>
> - A complete X.509 certificate in DER form (IN TLSA X 0 0
> ...)
> - A complete SPKI public-key in DER form (IN TLSA X 1 0 ...)
> - A binary SHA-256 digest of one of the above (IN TLSA X Y 1 ...)
> - A binary SHA-512 digest of one of the above (IN TLSA X Y 2 ...)
>
> where "X" is the certificate usage.
>
> When X is 0 or 2, the certificate association publishes a property
> of a root or intermediate CA that (possibly through a chain of
> intermediate CAs) ultimately issued the certificate of mumble.example.com.
>
> When X is 1 or 3, the certificate association publishes a property
> of the actual certificate whose public key is the public key of
> mumble.example.com.
>
> Whether you choose X = 0, 1, 2 or 3 is
>
> - part operational considerations (who updates the DNS in your
> organization, how often are server keys rotated, ...). Do
> you optimize for robustness in the face of buggy client
> implementations (simpler is better, and nothing is simpler
> than X=3) or robustness in the face of lazy operators who
> neglect to coordinate key rollover with DNS updates (X=0 or
> 2 requires less work for the DNS operator).
>
> - part application considerations, is the client pre-configured with
> a suitable list of trusted CAs? Does the client have a secure way
> to determine the service hostname (mumble.example.com), ...
>
> - part security considerations? Which risks do you want to mitigate?
> DNSSEC zone signingkey compromises? Rogue public CAs? Server
> key compromises? Do your clients consult CA revocation lists?
> How often are these lists updated? How quickly can you publish
> a revocation? ...
>
> - part PKI politics. Does your organization fervently believe in either
> of the two PKI models (public CAs or DANE) and distance itself from the
> other?
>
> Keep in mind that when keys change some clients will have older DNSSEC
> records in their caches, so you may need to publish both the old and the
> new association values when transitioning between and old and a new
> certificate (be it a CA or a server certificate). DANE validation will
> work provided at least association matches.
>
<snip/>
#!/usr/bin/perl
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# der2tlsa.pl
# Author: Bright Star. (bry 8 st ar \@a.t\@ ya hoo d.o.t c om)
# Author: tom/tm604.
#
# SSL DER to TLSA CAD.
# Change filename from "der2tlsa_pl" into "der2tlsa.pl"
# before using.
# To create a DER SSL/TLS cert file,
# from a PEM or CRT file:
# $ openssl x509 -in SSL-cert-file.pub.pem \
# -outform DER \
# -out SSL-cert-file.pub.der
# Do not specify .crt, .pem file in commandline,
# then it will show wrong codes.
# To Convert DER content into equivalent
# TLSA Hexadecimal, and Create Hash of DER content:
use Digest::SHA qw(sha256_hex sha512_hex);
$rFN = ""; $rFN = $ARGV[0];
$m = " v1.0.201307030000. Bright Star \(bry "
."8 st ar \@a.t\@ ya hoo d.o.t c om\)\n";
die "SSL DER 2 TLSA CAD\: Specify a DER "
."based SSL filename in commandline.\n$m"
unless $rFN;
printf "SSL DER 2 TLSA CAD:\n$m\nAttempting "
."to load \"$rFN\" file...";
open my $rFH, "<", $rFN or die
" Failed To Load $rFN File For Reading: $!\n";
{ local $/; $der = <$rFH>; }
close $rFH || warn
" Failed To Close $rFN File: $!\n";
printf " loading done.\n\n";
$full_cad = $der;
$full_cad =~ s/(.)/sprintf("%02X", ord($1))/egs;
$m = "\; a DNSSEC DANE/TLSA DNS record syntax\:\n"
."\; _port._proto.[host.]domain.TLD. [TTL] IN TLSA u s m C_A_D\n\n"
."\; Replace below \"u\", based on SSL/TLS certificate\'s \"usage\"\n"
."\; field, mentioned in\:\n"
."\; https\://tools\.ietf\.org/html/rfc6698\n"
."\; Brief/Summary: \"u\" can be replaced with any one of these numbers\: 0,
1,\n"
."\; 2, 3. \"s\" can be 0 or 1, \"m\" can be 0, 1 or 2. A purchased SSL cert
\(EE\)\n"
."\; from a known \(Public\) CA company which has their RootCA SSL cert
already\n"
."\; pre-included in popular web-browsers, client-software, operating
systems,\n"
."\; etc then declare such EE cert via \"TLSA 1 s m\" type of TLSA DNS
record.\n"
."\; If domain-owner created own self-signed \(EE\) srvr SSL cert, then
either\n"
."\; declare via \"TLSA 1 s m\", or, via \"TLSA 3 s m\". When \"u\" is 0, 1 or
2,\n"
."\; then DANE supported clients check Server SSL cert\'s entire \(PKIX\)
chain.\n"
."\; When \"u\" is 3, then clients skip checking chain. If you want to
declare\n"
."\; \(Public\) CA company\'s RootCA SSL cert, then use \"TLSA 0 s m\". To
declare\n"
."\; a Root-CA SSL cert which you yourself created, or when a Root-CA SSL
cert\n"
."\; is by-default not pre-included in web-browsers or client software or OS,\n"
."\; then use \"TLSA 2 s m\". When s=0 then C_A_D is based on Full SSL/TLS
cert,\n"
."\; when s=1 then C_A_D is based ONLY on SPKI \(SubjectPublicKeyInfo\)
portion\n"
."\; of a SSL cert. When m=0, then C_A_D has Full data of what is mentioned
in\n"
."\; \"s\", when m=1 then C_A_D is based on SHA-256 hash code of \"s\", when
m=2\n"
."\; then C_A_D is based on SHA-512. C_A_D = Certificate Association Data.
CAD\n"
."\; = C_A_D. TTL = Time To Live, in seconds. proto=protocol. TLD = Top Level\n"
."\; Domain.\n\n"
."\; A Full C_A_D hexadecimal code of Full SSL cert\:\n\n"
."_443._tcp.www\.example\.com. 900 IN "
."TLSA u 0 0 $full_cad\n\n";
my $sha = Digest::SHA->new(256);
$sha->addfile($rFN, "b");
$sha256 = uc $sha->hexdigest;
$m .= "\; SHA-256 based C_A_D of Full SSL cert\:\n\n"
."_443._tcp.www\.example\.com. 900 IN "
."TLSA u 0 1 $sha256\n\n";
$sha = Digest::SHA->reset(512);
$sha->addfile($rFN, "b");
$sha512 = uc $sha->hexdigest;
$m .= "\; SHA-512 based C_A_D of Full SSL cert\:\n\n"
."_443._tcp.www\.example\.com. 900 IN "
."TLSA u 0 2 $sha512\n\n";
printf "$m";
$wFN = $rFN . ".cad.tlsa";
printf "Attempting to create \(or over-write\) "
."\"$wFN\"...";
open my $wFH, ">", $wFN or die
" Could Not Create \(or OverWrite\) $wFN File "
."For Writing: $!\n";
{ print $wFH "$m"; }
close($wFH) || warn
" Failed To Close $wFN File: $!\n";
printf " file created, info saved.\n";
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
signature.asc
Description: OpenPGP digital signature
_______________________________________________ dane mailing list [email protected] https://www.ietf.org/mailman/listinfo/dane
