s, result = resolver.resolve(name, rrtype=RR_TYPE_SOA)
if 0 != s:
ub_strerror(s)
- return
+ return 3
if not result.secure:
print("CRIT (does not verify) %s" % (name, ))
+ return 2
s, packet = ldns.ldns_wire2pkt(result.packet)
rrsigs = packet.rr_list_by_type(RR_TYPE_RRSIG, ldns.LDNS_SECTION_ANSWER).rrs()
if delta < crit:
print("CRIT (expires in %s) %s" % (delta, name))
+ return 2
elif delta < warn:
print("WARN (expires in %s) %s" % (delta, name))
+ return 1
+ return 0
def main():
resolver = ub_ctx()
resolver.add_ta_file(opts.ancor)
encoding = sys.getfilesystemencoding()
-
+
+ final = 0
for name in opts.names:
- check_dnssec_expire(resolver, idn2dname(name.decode(encoding)),
- timedelta(opts.warn), timedelta(opts.crit))
+ result = check_dnssec_expire(resolver, idn2dname(name.decode(encoding)),
+ timedelta(opts.warn), timedelta(opts.crit))
+ if result == 2:
+ final = 2
+ elif result == 1 and final != 2:
+ final = 1
+ elif result == 3 and final not in [1, 2]:
+ final = 3
+
+ sys.exit(final)
if __name__ == "__main__":
main()