On 01/08/2018 07:41, Boobie Liu wrote:
Hi Boobie,
> Thank you for your answer.
>
> I've tried,but it didn't worked as except.Am I wrong?
See below, for errors:
> import dns.message
> import dns.rdatatype
> import dns.opcode
> import dns.flags
> import dns.query
> import dns.tsigkeyring
>
>
> keyring = dns.tsigkeyring.from_text({"boboieliutest":"****"})
>
> resolver = dns.resolver.Resolver()
> resolver.nameservers = [socket.gethostbyname(dns_server)]
>
> notify = dns.message.make_query('
boobieliu.com', dns.rdatatype.SOA)
> notify.keryring=keyring
You have a typo here - keryring. It should be keyring.
Next, even though you have associated a keyring with the notify message,
you haven't told it which key to use. You additionally need:
notify.keyname=dns.name.from_text('boboieliutest')
However, instead of setting the keyring and keyname variables
individually, you can do:
notify.use_tsig(keying, keyname='boboieliutest')
Also note that if you don't specify the TSIG algorithm it will default
to HMAC_MD5. So you need to do:
notify.use_tsig(keying, keyname='boboieliutest',
algorithm=dns.tsig.HMAC_SHA256)
to use a different TSIG algorithm.
This last part is a bit strange, because in my opinion, the algorithm
should be stored in the keyring, but the dns.tsigkeyring class doesn't
seem to understand algorithms. It just associates a key name with the
key material.
Regards,
Anand