code: public boolean validateTLSA(URL url) throws ValidSelfSignedCertException {
  
          TLSARecord tlsaRecord = getTLSARecord(url);
          if(tlsaRecord == null) {
              return false;
          }
  
          List<Certificate> certs = getUrlCerts(url);
          if(certs == null || certs.size() == 0) {
              return false;
          }
  
          // Get Cert Matching Selector and Matching Type Fields
          Certificate matchingCert = getMatchingCert(tlsaRecord, certs);
          if (matchingCert == null) {
              return false;
          }
  
          // Check for single cert / self-signed and validate
          switch(tlsaRecord.getCertificateUsage()) {
              case TLSARecord.CertificateUsage.CA_CONSTRAINT:
                  if(isValidCertChain(matchingCert, certs) && matchingCert != certs.get(0)) {
                      return true;
                  }
                  break;
              case TLSARecord.CertificateUsage.SERVICE_CERTIFICATE_CONSTRAINT:
                  if(isValidCertChain(matchingCert, certs) && matchingCert == certs.get(0)) {
                      return true;
                  }
                  break;
              case TLSARecord.CertificateUsage.TRUST_ANCHOR_ASSERTION:
                  if(isValidCertChain(certs.get(0), certs) && matchingCert == certs.get(certs.size() - 1)) {
                      throw new ValidSelfSignedCertException(matchingCert);
                  }
                  break;
              case TLSARecord.CertificateUsage.DOMAIN_ISSUED_CERTIFICATE:
                  // We've found a matching cert that does not require PKIX Chain Validation [RFC6698]
                  throw new ValidSelfSignedCertException(matchingCert);
          }
  
          return false;
      }
docs: Validates a URL's TLSA Record
  
  If the TLSA Record for the URL does not exist, validation fails.
  
  @param url URL Root to Generate TLSA record query
  @return TLSA Validated or not (boolean)
  @throws ValidSelfSignedCertException Return Matching Self Signed Cert for Inclusion into CertStore