readelf: report ARM program and section header types
[freebsd-src.git] / contrib / ldns / dane.c
blob675dfa8bf33599d4d4cfff0be726978a295c4eb5
1 /*
2 * Verify or create TLS authentication with DANE (RFC6698)
4 * (c) NLnetLabs 2012
6 * See the file LICENSE for the license.
8 */
10 #include <ldns/config.h>
11 #ifdef USE_DANE
13 #include <ldns/ldns.h>
14 #include <ldns/dane.h>
16 #include <unistd.h>
17 #include <stdlib.h>
18 #include <sys/types.h>
19 #ifdef HAVE_SYS_SOCKET_H
20 #include <sys/socket.h>
21 #endif
22 #ifdef HAVE_NETDB_H
23 #include <netdb.h>
24 #endif
26 #ifdef HAVE_SSL
27 #include <openssl/ssl.h>
28 #include <openssl/err.h>
29 #include <openssl/x509v3.h>
30 #endif
32 ldns_status
33 ldns_dane_create_tlsa_owner(ldns_rdf** tlsa_owner, const ldns_rdf* name,
34 uint16_t port, ldns_dane_transport transport)
36 char buf[LDNS_MAX_DOMAINLEN];
37 size_t s;
39 assert(tlsa_owner != NULL);
40 assert(name != NULL);
41 assert(ldns_rdf_get_type(name) == LDNS_RDF_TYPE_DNAME);
43 s = (size_t)snprintf(buf, LDNS_MAX_DOMAINLEN, "X_%d", (int)port);
44 buf[0] = (char)(s - 1);
46 switch(transport) {
47 case LDNS_DANE_TRANSPORT_TCP:
48 s += snprintf(buf + s, LDNS_MAX_DOMAINLEN - s, "\004_tcp");
49 break;
51 case LDNS_DANE_TRANSPORT_UDP:
52 s += snprintf(buf + s, LDNS_MAX_DOMAINLEN - s, "\004_udp");
53 break;
55 case LDNS_DANE_TRANSPORT_SCTP:
56 s += snprintf(buf + s, LDNS_MAX_DOMAINLEN - s, "\005_sctp");
57 break;
59 default:
60 return LDNS_STATUS_DANE_UNKNOWN_TRANSPORT;
62 if (s + ldns_rdf_size(name) > LDNS_MAX_DOMAINLEN) {
63 return LDNS_STATUS_DOMAINNAME_OVERFLOW;
65 memcpy(buf + s, ldns_rdf_data(name), ldns_rdf_size(name));
66 *tlsa_owner = ldns_rdf_new_frm_data(LDNS_RDF_TYPE_DNAME,
67 s + ldns_rdf_size(name), buf);
68 if (*tlsa_owner == NULL) {
69 return LDNS_STATUS_MEM_ERR;
71 return LDNS_STATUS_OK;
75 #ifdef HAVE_SSL
76 ldns_status
77 ldns_dane_cert2rdf(ldns_rdf** rdf, X509* cert,
78 ldns_tlsa_selector selector,
79 ldns_tlsa_matching_type matching_type)
81 unsigned char* buf = NULL;
82 size_t len;
84 X509_PUBKEY* xpubkey;
85 EVP_PKEY* epubkey;
87 unsigned char* digest;
89 assert(rdf != NULL);
90 assert(cert != NULL);
92 switch(selector) {
93 case LDNS_TLSA_SELECTOR_FULL_CERTIFICATE:
95 len = (size_t)i2d_X509(cert, &buf);
96 break;
98 case LDNS_TLSA_SELECTOR_SUBJECTPUBLICKEYINFO:
100 #ifndef S_SPLINT_S
101 xpubkey = X509_get_X509_PUBKEY(cert);
102 #endif
103 if (! xpubkey) {
104 return LDNS_STATUS_SSL_ERR;
106 epubkey = X509_PUBKEY_get(xpubkey);
107 if (! epubkey) {
108 return LDNS_STATUS_SSL_ERR;
110 len = (size_t)i2d_PUBKEY(epubkey, &buf);
111 break;
113 default:
114 return LDNS_STATUS_DANE_UNKNOWN_SELECTOR;
117 switch(matching_type) {
118 case LDNS_TLSA_MATCHING_TYPE_NO_HASH_USED:
120 *rdf = ldns_rdf_new(LDNS_RDF_TYPE_HEX, len, buf);
122 return *rdf ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR;
123 break;
125 case LDNS_TLSA_MATCHING_TYPE_SHA256:
127 digest = LDNS_XMALLOC(unsigned char, LDNS_SHA256_DIGEST_LENGTH);
128 if (digest == NULL) {
129 LDNS_FREE(buf);
130 return LDNS_STATUS_MEM_ERR;
132 (void) ldns_sha256(buf, (unsigned int)len, digest);
133 *rdf = ldns_rdf_new(LDNS_RDF_TYPE_HEX, LDNS_SHA256_DIGEST_LENGTH,
134 digest);
135 LDNS_FREE(buf);
137 return *rdf ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR;
138 break;
140 case LDNS_TLSA_MATCHING_TYPE_SHA512:
142 digest = LDNS_XMALLOC(unsigned char, LDNS_SHA512_DIGEST_LENGTH);
143 if (digest == NULL) {
144 LDNS_FREE(buf);
145 return LDNS_STATUS_MEM_ERR;
147 (void) ldns_sha512(buf, (unsigned int)len, digest);
148 *rdf = ldns_rdf_new(LDNS_RDF_TYPE_HEX, LDNS_SHA512_DIGEST_LENGTH,
149 digest);
150 LDNS_FREE(buf);
152 return *rdf ? LDNS_STATUS_OK : LDNS_STATUS_MEM_ERR;
153 break;
155 default:
156 LDNS_FREE(buf);
157 return LDNS_STATUS_DANE_UNKNOWN_MATCHING_TYPE;
162 /* Ordinary PKIX validation of cert (with extra_certs to help)
163 * against the CA's in store
165 static ldns_status
166 ldns_dane_pkix_validate(X509* cert, STACK_OF(X509)* extra_certs,
167 X509_STORE* store)
169 X509_STORE_CTX* vrfy_ctx;
170 ldns_status s;
172 if (! store) {
173 return LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE;
175 vrfy_ctx = X509_STORE_CTX_new();
176 if (! vrfy_ctx) {
178 return LDNS_STATUS_SSL_ERR;
180 } else if (X509_STORE_CTX_init(vrfy_ctx, store,
181 cert, extra_certs) != 1) {
182 s = LDNS_STATUS_SSL_ERR;
184 } else if (X509_verify_cert(vrfy_ctx) == 1) {
186 s = LDNS_STATUS_OK;
188 } else {
189 s = LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE;
191 X509_STORE_CTX_free(vrfy_ctx);
192 return s;
196 /* Orinary PKIX validation of cert (with extra_certs to help)
197 * against the CA's in store, but also return the validation chain.
199 static ldns_status
200 ldns_dane_pkix_validate_and_get_chain(STACK_OF(X509)** chain, X509* cert,
201 STACK_OF(X509)* extra_certs, X509_STORE* store)
203 ldns_status s;
204 X509_STORE* empty_store = NULL;
205 X509_STORE_CTX* vrfy_ctx;
207 assert(chain != NULL);
209 if (! store) {
210 store = empty_store = X509_STORE_new();
212 s = LDNS_STATUS_SSL_ERR;
213 vrfy_ctx = X509_STORE_CTX_new();
214 if (! vrfy_ctx) {
216 goto exit_free_empty_store;
218 } else if (X509_STORE_CTX_init(vrfy_ctx, store,
219 cert, extra_certs) != 1) {
220 goto exit_free_vrfy_ctx;
222 } else if (X509_verify_cert(vrfy_ctx) == 1) {
224 s = LDNS_STATUS_OK;
226 } else {
227 s = LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE;
229 *chain = X509_STORE_CTX_get1_chain(vrfy_ctx);
230 if (! *chain) {
231 s = LDNS_STATUS_SSL_ERR;
234 exit_free_vrfy_ctx:
235 X509_STORE_CTX_free(vrfy_ctx);
237 exit_free_empty_store:
238 if (empty_store) {
239 X509_STORE_free(empty_store);
241 return s;
245 /* Return the validation chain that can be build out of cert, with extra_certs.
247 static ldns_status
248 ldns_dane_pkix_get_chain(STACK_OF(X509)** chain,
249 X509* cert, STACK_OF(X509)* extra_certs)
251 ldns_status s;
252 X509_STORE* empty_store = NULL;
253 X509_STORE_CTX* vrfy_ctx;
255 assert(chain != NULL);
257 empty_store = X509_STORE_new();
258 s = LDNS_STATUS_SSL_ERR;
259 vrfy_ctx = X509_STORE_CTX_new();
260 if (! vrfy_ctx) {
262 goto exit_free_empty_store;
264 } else if (X509_STORE_CTX_init(vrfy_ctx, empty_store,
265 cert, extra_certs) != 1) {
266 goto exit_free_vrfy_ctx;
268 (void) X509_verify_cert(vrfy_ctx);
269 *chain = X509_STORE_CTX_get1_chain(vrfy_ctx);
270 if (! *chain) {
271 s = LDNS_STATUS_SSL_ERR;
272 } else {
273 s = LDNS_STATUS_OK;
275 exit_free_vrfy_ctx:
276 X509_STORE_CTX_free(vrfy_ctx);
278 exit_free_empty_store:
279 X509_STORE_free(empty_store);
280 return s;
284 /* Pop n+1 certs and return the last popped.
286 static ldns_status
287 ldns_dane_get_nth_cert_from_validation_chain(
288 X509** cert, STACK_OF(X509)* chain, int n, bool ca)
290 if (n >= sk_X509_num(chain) || n < 0) {
291 return LDNS_STATUS_DANE_OFFSET_OUT_OF_RANGE;
293 *cert = sk_X509_pop(chain);
294 while (n-- > 0) {
295 X509_free(*cert);
296 *cert = sk_X509_pop(chain);
298 if (ca && ! X509_check_ca(*cert)) {
299 return LDNS_STATUS_DANE_NON_CA_CERTIFICATE;
301 return LDNS_STATUS_OK;
305 /* Create validation chain with cert and extra_certs and returns the last
306 * self-signed (if present).
308 static ldns_status
309 ldns_dane_pkix_get_last_self_signed(X509** out_cert,
310 X509* cert, STACK_OF(X509)* extra_certs)
312 ldns_status s;
313 X509_STORE* empty_store = NULL;
314 X509_STORE_CTX* vrfy_ctx;
316 assert(out_cert != NULL);
318 empty_store = X509_STORE_new();
319 s = LDNS_STATUS_SSL_ERR;
320 vrfy_ctx = X509_STORE_CTX_new();
321 if (! vrfy_ctx) {
322 goto exit_free_empty_store;
324 } else if (X509_STORE_CTX_init(vrfy_ctx, empty_store,
325 cert, extra_certs) != 1) {
326 goto exit_free_vrfy_ctx;
329 (void) X509_verify_cert(vrfy_ctx);
330 if (vrfy_ctx->error == X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN ||
331 vrfy_ctx->error == X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT){
333 *out_cert = X509_STORE_CTX_get_current_cert( vrfy_ctx);
334 s = LDNS_STATUS_OK;
335 } else {
336 s = LDNS_STATUS_DANE_PKIX_NO_SELF_SIGNED_TRUST_ANCHOR;
338 exit_free_vrfy_ctx:
339 X509_STORE_CTX_free(vrfy_ctx);
341 exit_free_empty_store:
342 X509_STORE_free(empty_store);
343 return s;
347 ldns_status
348 ldns_dane_select_certificate(X509** selected_cert,
349 X509* cert, STACK_OF(X509)* extra_certs,
350 X509_STORE* pkix_validation_store,
351 ldns_tlsa_certificate_usage cert_usage, int offset)
353 ldns_status s;
354 STACK_OF(X509)* pkix_validation_chain = NULL;
356 assert(selected_cert != NULL);
357 assert(cert != NULL);
359 /* With PKIX validation explicitely turned off (pkix_validation_store
360 * == NULL), treat the "CA constraint" and "Service certificate
361 * constraint" the same as "Trust anchor assertion" and "Domain issued
362 * certificate" respectively.
364 if (pkix_validation_store == NULL) {
365 switch (cert_usage) {
367 case LDNS_TLSA_USAGE_CA_CONSTRAINT:
369 cert_usage = LDNS_TLSA_USAGE_TRUST_ANCHOR_ASSERTION;
370 break;
372 case LDNS_TLSA_USAGE_SERVICE_CERTIFICATE_CONSTRAINT:
374 cert_usage = LDNS_TLSA_USAGE_DOMAIN_ISSUED_CERTIFICATE;
375 break;
377 default:
378 break;
382 /* Now what to do with each Certificate usage...
384 switch (cert_usage) {
386 case LDNS_TLSA_USAGE_CA_CONSTRAINT:
388 s = ldns_dane_pkix_validate_and_get_chain(
389 &pkix_validation_chain,
390 cert, extra_certs,
391 pkix_validation_store);
392 if (! pkix_validation_chain) {
393 return s;
395 if (s == LDNS_STATUS_OK) {
396 if (offset == -1) {
397 offset = 0;
399 s = ldns_dane_get_nth_cert_from_validation_chain(
400 selected_cert, pkix_validation_chain,
401 offset, true);
403 sk_X509_pop_free(pkix_validation_chain, X509_free);
404 return s;
405 break;
408 case LDNS_TLSA_USAGE_SERVICE_CERTIFICATE_CONSTRAINT:
410 *selected_cert = cert;
411 return ldns_dane_pkix_validate(cert, extra_certs,
412 pkix_validation_store);
413 break;
416 case LDNS_TLSA_USAGE_TRUST_ANCHOR_ASSERTION:
418 if (offset == -1) {
419 s = ldns_dane_pkix_get_last_self_signed(
420 selected_cert, cert, extra_certs);
421 return s;
422 } else {
423 s = ldns_dane_pkix_get_chain(
424 &pkix_validation_chain,
425 cert, extra_certs);
426 if (s == LDNS_STATUS_OK) {
428 ldns_dane_get_nth_cert_from_validation_chain(
429 selected_cert, pkix_validation_chain,
430 offset, false);
431 } else if (! pkix_validation_chain) {
432 return s;
434 sk_X509_pop_free(pkix_validation_chain, X509_free);
435 return s;
437 break;
440 case LDNS_TLSA_USAGE_DOMAIN_ISSUED_CERTIFICATE:
442 *selected_cert = cert;
443 return LDNS_STATUS_OK;
444 break;
446 default:
447 return LDNS_STATUS_DANE_UNKNOWN_CERTIFICATE_USAGE;
448 break;
453 ldns_status
454 ldns_dane_create_tlsa_rr(ldns_rr** tlsa,
455 ldns_tlsa_certificate_usage certificate_usage,
456 ldns_tlsa_selector selector,
457 ldns_tlsa_matching_type matching_type,
458 X509* cert)
460 ldns_rdf* rdf;
461 ldns_status s;
463 assert(tlsa != NULL);
464 assert(cert != NULL);
466 /* create rr */
467 *tlsa = ldns_rr_new_frm_type(LDNS_RR_TYPE_TLSA);
468 if (*tlsa == NULL) {
469 return LDNS_STATUS_MEM_ERR;
472 rdf = ldns_native2rdf_int8(LDNS_RDF_TYPE_INT8,
473 (uint8_t)certificate_usage);
474 if (rdf == NULL) {
475 goto memerror;
477 (void) ldns_rr_set_rdf(*tlsa, rdf, 0);
479 rdf = ldns_native2rdf_int8(LDNS_RDF_TYPE_INT8, (uint8_t)selector);
480 if (rdf == NULL) {
481 goto memerror;
483 (void) ldns_rr_set_rdf(*tlsa, rdf, 1);
485 rdf = ldns_native2rdf_int8(LDNS_RDF_TYPE_INT8, (uint8_t)matching_type);
486 if (rdf == NULL) {
487 goto memerror;
489 (void) ldns_rr_set_rdf(*tlsa, rdf, 2);
491 s = ldns_dane_cert2rdf(&rdf, cert, selector, matching_type);
492 if (s == LDNS_STATUS_OK) {
493 (void) ldns_rr_set_rdf(*tlsa, rdf, 3);
494 return LDNS_STATUS_OK;
496 ldns_rr_free(*tlsa);
497 *tlsa = NULL;
498 return s;
500 memerror:
501 ldns_rr_free(*tlsa);
502 *tlsa = NULL;
503 return LDNS_STATUS_MEM_ERR;
507 /* Return tlsas that actually are TLSA resource records with known values
508 * for the Certificate usage, Selector and Matching type rdata fields.
510 static ldns_rr_list*
511 ldns_dane_filter_unusable_records(const ldns_rr_list* tlsas)
513 size_t i;
514 ldns_rr_list* r = ldns_rr_list_new();
515 ldns_rr* tlsa_rr;
517 if (! r) {
518 return NULL;
520 for (i = 0; i < ldns_rr_list_rr_count(tlsas); i++) {
521 tlsa_rr = ldns_rr_list_rr(tlsas, i);
522 if (ldns_rr_get_type(tlsa_rr) == LDNS_RR_TYPE_TLSA &&
523 ldns_rr_rd_count(tlsa_rr) == 4 &&
524 ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 0)) <= 3 &&
525 ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 1)) <= 1 &&
526 ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 2)) <= 2) {
528 if (! ldns_rr_list_push_rr(r, tlsa_rr)) {
529 ldns_rr_list_free(r);
530 return NULL;
534 return r;
538 /* Return whether cert/selector/matching_type matches data.
540 static ldns_status
541 ldns_dane_match_cert_with_data(X509* cert, ldns_tlsa_selector selector,
542 ldns_tlsa_matching_type matching_type, ldns_rdf* data)
544 ldns_status s;
545 ldns_rdf* match_data;
547 s = ldns_dane_cert2rdf(&match_data, cert, selector, matching_type);
548 if (s == LDNS_STATUS_OK) {
549 if (ldns_rdf_compare(data, match_data) != 0) {
550 s = LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH;
552 ldns_rdf_free(match_data);
554 return s;
558 /* Return whether any certificate from the chain with selector/matching_type
559 * matches data.
560 * ca should be true if the certificate has to be a CA certificate too.
562 static ldns_status
563 ldns_dane_match_any_cert_with_data(STACK_OF(X509)* chain,
564 ldns_tlsa_selector selector,
565 ldns_tlsa_matching_type matching_type,
566 ldns_rdf* data, bool ca)
568 ldns_status s = LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH;
569 size_t n, i;
570 X509* cert;
572 n = (size_t)sk_X509_num(chain);
573 for (i = 0; i < n; i++) {
574 cert = sk_X509_pop(chain);
575 if (! cert) {
576 s = LDNS_STATUS_SSL_ERR;
577 break;
579 s = ldns_dane_match_cert_with_data(cert,
580 selector, matching_type, data);
581 if (ca && s == LDNS_STATUS_OK && ! X509_check_ca(cert)) {
582 s = LDNS_STATUS_DANE_NON_CA_CERTIFICATE;
584 X509_free(cert);
585 if (s != LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH) {
586 break;
588 /* when s == LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH,
589 * try to match the next certificate
592 return s;
596 ldns_status
597 ldns_dane_verify_rr(const ldns_rr* tlsa_rr,
598 X509* cert, STACK_OF(X509)* extra_certs,
599 X509_STORE* pkix_validation_store)
601 ldns_status s;
603 STACK_OF(X509)* pkix_validation_chain = NULL;
605 ldns_tlsa_certificate_usage cert_usage;
606 ldns_tlsa_selector selector;
607 ldns_tlsa_matching_type matching_type;
608 ldns_rdf* data;
610 if (! tlsa_rr) {
611 /* No TLSA, so regular PKIX validation
613 return ldns_dane_pkix_validate(cert, extra_certs,
614 pkix_validation_store);
616 cert_usage = ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 0));
617 selector = ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 1));
618 matching_type = ldns_rdf2native_int8(ldns_rr_rdf(tlsa_rr, 2));
619 data = ldns_rr_rdf(tlsa_rr, 3) ;
621 switch (cert_usage) {
622 case LDNS_TLSA_USAGE_CA_CONSTRAINT:
623 s = ldns_dane_pkix_validate_and_get_chain(
624 &pkix_validation_chain,
625 cert, extra_certs,
626 pkix_validation_store);
627 if (! pkix_validation_chain) {
628 return s;
630 if (s == LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE) {
632 * NO PKIX validation. We still try to match *any*
633 * certificate from the chain, so we return
634 * TLSA errors over PKIX errors.
636 * i.e. When the TLSA matches no certificate, we return
637 * TLSA_DID_NOT_MATCH and not PKIX_DID_NOT_VALIDATE
639 s = ldns_dane_match_any_cert_with_data(
640 pkix_validation_chain,
641 selector, matching_type, data, true);
643 if (s == LDNS_STATUS_OK) {
644 /* A TLSA record did match a cert from the
645 * chain, thus the error is failed PKIX
646 * validation.
648 s = LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE;
651 } else if (s == LDNS_STATUS_OK) {
652 /* PKIX validated, does the TLSA match too? */
654 s = ldns_dane_match_any_cert_with_data(
655 pkix_validation_chain,
656 selector, matching_type, data, true);
658 sk_X509_pop_free(pkix_validation_chain, X509_free);
659 return s;
660 break;
662 case LDNS_TLSA_USAGE_SERVICE_CERTIFICATE_CONSTRAINT:
663 s = ldns_dane_match_cert_with_data(cert,
664 selector, matching_type, data);
666 if (s == LDNS_STATUS_OK) {
667 return ldns_dane_pkix_validate(cert, extra_certs,
668 pkix_validation_store);
670 return s;
671 break;
673 case LDNS_TLSA_USAGE_TRUST_ANCHOR_ASSERTION:
674 s = ldns_dane_pkix_get_chain(&pkix_validation_chain,
675 cert, extra_certs);
677 if (s == LDNS_STATUS_OK) {
678 s = ldns_dane_match_any_cert_with_data(
679 pkix_validation_chain,
680 selector, matching_type, data, false);
682 } else if (! pkix_validation_chain) {
683 return s;
685 sk_X509_pop_free(pkix_validation_chain, X509_free);
686 return s;
687 break;
689 case LDNS_TLSA_USAGE_DOMAIN_ISSUED_CERTIFICATE:
690 return ldns_dane_match_cert_with_data(cert,
691 selector, matching_type, data);
692 break;
694 default:
695 break;
697 return LDNS_STATUS_DANE_UNKNOWN_CERTIFICATE_USAGE;
701 ldns_status
702 ldns_dane_verify(ldns_rr_list* tlsas,
703 X509* cert, STACK_OF(X509)* extra_certs,
704 X509_STORE* pkix_validation_store)
706 size_t i;
707 ldns_rr* tlsa_rr;
708 ldns_status s = LDNS_STATUS_OK, ps;
710 assert(cert != NULL);
712 if (tlsas && ldns_rr_list_rr_count(tlsas) > 0) {
713 tlsas = ldns_dane_filter_unusable_records(tlsas);
714 if (! tlsas) {
715 return LDNS_STATUS_MEM_ERR;
718 if (! tlsas || ldns_rr_list_rr_count(tlsas) == 0) {
719 /* No TLSA's, so regular PKIX validation
721 return ldns_dane_pkix_validate(cert, extra_certs,
722 pkix_validation_store);
723 } else {
724 for (i = 0; i < ldns_rr_list_rr_count(tlsas); i++) {
725 tlsa_rr = ldns_rr_list_rr(tlsas, i);
726 ps = s;
727 s = ldns_dane_verify_rr(tlsa_rr, cert, extra_certs,
728 pkix_validation_store);
730 if (s != LDNS_STATUS_DANE_TLSA_DID_NOT_MATCH &&
731 s != LDNS_STATUS_DANE_PKIX_DID_NOT_VALIDATE) {
733 /* which would be LDNS_STATUS_OK (match)
734 * or some fatal error preventing use from
735 * trying the next TLSA record.
737 break;
739 s = (s > ps ? s : ps); /* prefer PKIX_DID_NOT_VALIDATE
740 * over TLSA_DID_NOT_MATCH
743 ldns_rr_list_free(tlsas);
745 return s;
747 #endif /* HAVE_SSL */
748 #endif /* USE_DANE */