pw.getHeader()->rcode=res;
if(edo.d_Z & EDNSOpts::DNSSECOK) {
- if(validateRecords(ret))
+ auto state=validateRecords(ret);
+ if(state == Secure) {
pw.getHeader()->ad=1;
- else {
+ }
+ else if(state == Insecure) {
+ pw.getHeader()->ad=0;
+ }
+ else if(state == Bogus && !pw.getHeader()->cd) {
pw.getHeader()->rcode=RCode::ServFail;
goto sendit;
}
SyncRes sr(tv);
vector<DNSRecord> ret;
- int res;
sr.d_doDNSSEC=true;
- res=sr.beginResolve(qname, QType(qtype), 1, ret);
+ sr.beginResolve(qname, QType(qtype), 1, ret);
d_queries += sr.d_outqueries;
return ret;
}
};
-bool validateRecords(const vector<DNSRecord>& recs)
+vState validateRecords(const vector<DNSRecord>& recs)
{
g_rootDS = "19036 8 2 49aac11d7b6f6446702e54a1607371607a1a41855200fd2ce1cdde32f24e8fb5";
cspmap_t cspmap=harvestCSPFromRecs(recs);
// cerr<<"Got "<<cspmap.size()<<" RRSETs: ";
int numsigs=0;
for(const auto& csp : cspmap) {
- // cerr<<" "<<csp.first.first<<'/'<<DNSRecordContent::NumberToType(csp.first.second)<<": "<<csp.second.signatures.size()<<" sigs for "<<csp.second.records.size()<<" records"<<endl;
+ // cerr<<"Going to validate: "<<csp.first.first<<'/'<<DNSRecordContent::NumberToType(csp.first.second)<<": "<<csp.second.signatures.size()<<" sigs for "<<csp.second.records.size()<<" records"<<endl;
numsigs+= csp.second.signatures.size();
}
if(numsigs) {
for(const auto& csp : cspmap) {
for(const auto& sig : csp.second.signatures) {
- // cerr<<"got rrsig "<<sig->d_signer<<"/"<<sig->d_tag<<endl;
vState state = getKeysFor(sro, sig->d_signer, keys);
// cerr<<"! state = "<<vStates[state]<<", now have "<<keys.size()<<" keys"<<endl;
- // dsmap.insert(make_pair(dsrc.d_tag, dsrc));
}
}
// cerr<<"no sigs, hoping for Insecure"<<endl;
vState state = getKeysFor(sro, recs.begin()->d_name, keys); // um WHAT DOES THIS MEAN - try first qname??
// cerr<<"! state = "<<vStates[state]<<", now have "<<keys.size()<<" keys "<<endl;
+ return state;
}
+
// cerr<<"! validated "<<validrrsets.size()<<" RRsets out of "<<cspmap.size()<<endl;
// cerr<<"% validated RRs:"<<endl;
}
}
// cerr<<"Took "<<sro.d_queries<<" queries"<<endl;
- return validrrsets.size() == cspmap.size();
+ if(validrrsets.size() == cspmap.size())
+ return Secure;
+ return Insecure;
}