example4.rst revision 238106
1238106Sdes.. _example_examine: 2238106Sdes 3238106Sdes============================== 4238106SdesDNSSEC validator 5238106Sdes============================== 6238106Sdes 7238106SdesThis example program performs DNSSEC validation of a DNS lookup. 8238106Sdes 9238106Sdes:: 10238106Sdes 11238106Sdes #!/usr/bin/python 12238106Sdes import os 13238106Sdes from unbound import ub_ctx,RR_TYPE_A,RR_CLASS_IN 14238106Sdes 15238106Sdes ctx = ub_ctx() 16238106Sdes ctx.resolvconf("/etc/resolv.conf") 17238106Sdes if (os.path.isfile("keys")): 18238106Sdes ctx.add_ta_file("keys") #read public keys for DNSSEC verification 19238106Sdes 20238106Sdes status, result = ctx.resolve("www.nic.cz", RR_TYPE_A, RR_CLASS_IN) 21238106Sdes if status == 0 and result.havedata: 22238106Sdes 23238106Sdes print "Result:", result.data.address_list 24238106Sdes 25238106Sdes if result.secure: 26238106Sdes print "Result is secure" 27238106Sdes elif result.bogus: 28238106Sdes print "Result is bogus" 29238106Sdes else: 30238106Sdes print "Result is insecure" 31238106Sdes 32238106SdesMore detailed informations can be seen in libUnbound DNSSEC tutorial `here`_. 33238106Sdes 34238106Sdes.. _here: http://www.unbound.net/documentation/libunbound-tutorial-6.html 35