mirror of https://github.com/getdnsapi/getdns.git
Fix TLS authentication
This commit is contained in:
parent
a9ba50dff1
commit
23daf9aac3
|
@ -3521,16 +3521,13 @@ _getdns_ns_dns_setup(struct getdns_context *context)
|
||||||
}
|
}
|
||||||
|
|
||||||
getdns_return_t
|
getdns_return_t
|
||||||
_getdns_context_prepare_for_resolution(struct getdns_context *context,
|
_getdns_context_prepare_for_resolution(getdns_context *context)
|
||||||
int usenamespaces)
|
|
||||||
{
|
{
|
||||||
size_t i;
|
|
||||||
getdns_return_t r;
|
getdns_return_t r;
|
||||||
|
|
||||||
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER);
|
||||||
if (context->destroying) {
|
if (context->destroying)
|
||||||
return GETDNS_RETURN_BAD_CONTEXT;
|
return GETDNS_RETURN_BAD_CONTEXT;
|
||||||
}
|
|
||||||
|
|
||||||
/* Transport can in theory be set per query in stub mode */
|
/* Transport can in theory be set per query in stub mode */
|
||||||
if (context->resolution_type == GETDNS_RESOLUTION_STUB &&
|
if (context->resolution_type == GETDNS_RESOLUTION_STUB &&
|
||||||
|
@ -3607,28 +3604,9 @@ _getdns_context_prepare_for_resolution(struct getdns_context *context,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if (! usenamespaces) {
|
r = _getdns_ns_dns_setup(context);
|
||||||
r = _getdns_ns_dns_setup(context);
|
if (r == GETDNS_RETURN_GOOD)
|
||||||
if (r == GETDNS_RETURN_GOOD)
|
context->resolution_type_set = context->resolution_type;
|
||||||
context->resolution_type_set = context->resolution_type;
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
r = GETDNS_RETURN_GOOD;
|
|
||||||
for (i = 0; i < context->namespace_count; i++) {
|
|
||||||
switch (context->namespaces[i]) {
|
|
||||||
case GETDNS_NAMESPACE_DNS:
|
|
||||||
r = _getdns_ns_dns_setup(context);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
r = GETDNS_RETURN_BAD_CONTEXT;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (r != GETDNS_RETURN_GOOD)
|
|
||||||
return r; /* try again later (resolution_type_set) */
|
|
||||||
}
|
|
||||||
context->resolution_type_set = context->resolution_type;
|
|
||||||
return r;
|
return r;
|
||||||
} /* _getdns_context_prepare_for_resolution */
|
} /* _getdns_context_prepare_for_resolution */
|
||||||
|
|
||||||
|
|
|
@ -495,11 +495,9 @@ void _getdns_context_log(getdns_context *context, uint64_t system,
|
||||||
* Sets up the unbound contexts with stub or recursive behavior
|
* Sets up the unbound contexts with stub or recursive behavior
|
||||||
* if needed.
|
* if needed.
|
||||||
* @param context previously initialized getdns_context
|
* @param context previously initialized getdns_context
|
||||||
* @param usenamespaces if 0 then only use the DNS, else use context namespace list
|
|
||||||
* @return GETDNS_RETURN_GOOD on success
|
* @return GETDNS_RETURN_GOOD on success
|
||||||
*/
|
*/
|
||||||
getdns_return_t _getdns_context_prepare_for_resolution(struct getdns_context *context,
|
getdns_return_t _getdns_context_prepare_for_resolution(getdns_context *context);
|
||||||
int usenamespaces);
|
|
||||||
|
|
||||||
/* Register a getdns_dns_req with context.
|
/* Register a getdns_dns_req with context.
|
||||||
* - Without pluggable unbound event API,
|
* - Without pluggable unbound event API,
|
||||||
|
|
|
@ -3284,7 +3284,7 @@ void _getdns_ta_notify_dnsreqs(getdns_context *context)
|
||||||
getdns_network_req *netreq, **netreq_p;
|
getdns_network_req *netreq, **netreq_p;
|
||||||
int r = GETDNS_RETURN_GOOD;
|
int r = GETDNS_RETURN_GOOD;
|
||||||
|
|
||||||
(void) _getdns_context_prepare_for_resolution(context, 0);
|
(void) _getdns_context_prepare_for_resolution(context);
|
||||||
|
|
||||||
*dnsreq_p = dnsreq->ta_notify;
|
*dnsreq_p = dnsreq->ta_notify;
|
||||||
for ( netreq_p = dnsreq->netreqs
|
for ( netreq_p = dnsreq->netreqs
|
||||||
|
|
|
@ -609,10 +609,11 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
|
||||||
context->ta_notify = req;
|
context->ta_notify = req;
|
||||||
return GETDNS_RETURN_GOOD;
|
return GETDNS_RETURN_GOOD;
|
||||||
}
|
}
|
||||||
(void) _getdns_context_prepare_for_resolution(context, 0);
|
if ((r = _getdns_context_prepare_for_resolution(context)))
|
||||||
|
; /* pass */
|
||||||
|
|
||||||
/* issue all network requests */
|
/* issue all network requests */
|
||||||
for ( netreq_p = req->netreqs
|
else for ( netreq_p = req->netreqs
|
||||||
; !r && (netreq = *netreq_p)
|
; !r && (netreq = *netreq_p)
|
||||||
; netreq_p++) {
|
; netreq_p++) {
|
||||||
if ((r = _getdns_submit_netreq(netreq, &now_ms))) {
|
if ((r = _getdns_submit_netreq(netreq, &now_ms))) {
|
||||||
|
@ -667,7 +668,8 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
|
||||||
context->ta_notify = req;
|
context->ta_notify = req;
|
||||||
return GETDNS_RETURN_GOOD;
|
return GETDNS_RETURN_GOOD;
|
||||||
}
|
}
|
||||||
(void) _getdns_context_prepare_for_resolution(context, 0);
|
if ((r = _getdns_context_prepare_for_resolution(context)))
|
||||||
|
break;
|
||||||
|
|
||||||
/* TODO: We will get a good return code here even if
|
/* TODO: We will get a good return code here even if
|
||||||
the name is not found (NXDOMAIN). We should consider
|
the name is not found (NXDOMAIN). We should consider
|
||||||
|
|
|
@ -170,7 +170,12 @@ network_req_init(getdns_network_req *net_req, getdns_dns_req *owner,
|
||||||
net_req->transport_count = owner->context->dns_transport_count;
|
net_req->transport_count = owner->context->dns_transport_count;
|
||||||
memcpy(net_req->transports, owner->context->dns_transports,
|
memcpy(net_req->transports, owner->context->dns_transports,
|
||||||
net_req->transport_count * sizeof(getdns_transport_list_t));
|
net_req->transport_count * sizeof(getdns_transport_list_t));
|
||||||
net_req->tls_auth_min = owner->context->tls_auth_min;
|
net_req->tls_auth_min =
|
||||||
|
owner->context->tls_auth == GETDNS_AUTHENTICATION_REQUIRED
|
||||||
|
&& owner->context->dns_transport_count == 1
|
||||||
|
&& owner->context->dns_transports[0] == GETDNS_TRANSPORT_TLS
|
||||||
|
? GETDNS_AUTHENTICATION_REQUIRED
|
||||||
|
: GETDNS_AUTHENTICATION_NONE;
|
||||||
|
|
||||||
net_req->follow_redirects = owner->context->follow_redirects;
|
net_req->follow_redirects = owner->context->follow_redirects;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue