]>
git.saurik.com Git - apple/network_cmds.git/blob - unbound/libunbound/python/examples/dnssec_test.py
0d62b9ff2154438daf49a5b6e3e0c31141b40a1a
2 from unbound
import ub_ctx
, RR_TYPE_A
, RR_TYPE_RRSIG
, RR_TYPE_NSEC
, RR_TYPE_NSEC3
5 def dnssecParse(domain
, rrType
=RR_TYPE_A
):
6 print("Resolving domain", domain
)
7 s
, r
= resolver
.resolve(domain
)
8 print("status: %s, secure: %s, rcode: %s, havedata: %s, answer_len; %s" % (s
, r
.secure
, r
.rcode_str
, r
.havedata
, r
.answer_len
))
10 s
, pkt
= ldns
.ldns_wire2pkt(r
.packet
)
12 raise RuntimeError("Error parsing DNS packet")
14 rrsigs
= pkt
.rr_list_by_type(RR_TYPE_RRSIG
, ldns
.LDNS_SECTION_ANSWER
)
15 print("RRSIGs from answer:", rrsigs
)
17 rrsigs
= pkt
.rr_list_by_type(RR_TYPE_RRSIG
, ldns
.LDNS_SECTION_AUTHORITY
)
18 print("RRSIGs from authority:", rrsigs
)
20 nsecs
= pkt
.rr_list_by_type(RR_TYPE_NSEC
, ldns
.LDNS_SECTION_AUTHORITY
)
21 print("NSECs:", nsecs
)
23 nsec3s
= pkt
.rr_list_by_type(RR_TYPE_NSEC3
, ldns
.LDNS_SECTION_AUTHORITY
)
24 print("NSEC3s:", nsec3s
)
30 resolver
.add_ta(". IN DS 19036 8 2 49AAC11D7B6F6446702E54A1607371607A1A41855200FD2CE1CDDE32F24E8FB5")
33 dnssecParse("nonexistent-domain-blablabla.cz")
34 dnssecParse("nonexistent-domain-blablabla.root.cz")