]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/unbound/libunbound/python/doc/examples/example4.rst
Upgrade Unbound to 1.6.7. More to follow.
[FreeBSD/FreeBSD.git] / contrib / unbound / libunbound / python / doc / examples / example4.rst
1 .. _example_examine:
2
3 DNSSEC validator
4 ================
5
6 This example program performs DNSSEC validation of a DNS lookup.
7
8 Source code
9 -----------
10
11 ::
12
13     #!/usr/bin/python
14     import os
15     from unbound import ub_ctx,RR_TYPE_A,RR_CLASS_IN
16
17     ctx = ub_ctx()
18     ctx.resolvconf("/etc/resolv.conf")
19     if (os.path.isfile("keys")):
20         ctx.add_ta_file("keys") #read public keys for DNSSEC verification
21
22     status, result = ctx.resolve("www.nic.cz", RR_TYPE_A, RR_CLASS_IN)
23     if status == 0 and result.havedata:
24
25         print "Result:", result.data.address_list
26
27         if result.secure:
28             print "Result is secure"
29         elif result.bogus:
30             print "Result is bogus"
31         else:
32             print "Result is insecure"
33
34 More detailed informations can be seen in libUnbound DNSSEC tutorial `here`_.
35
36 .. _here: http://www.unbound.net/documentation/libunbound-tutorial-6.html