Skip to content

error algo: fetchPublicKeys with dns_get_record #12

@jetsam729

Description

@jetsam729

validator.php line:296

    public static function fetchPublicKeys(string $domain, string $selector)
    {
        $host = sprintf('%s._domainkey.%s', $selector, $domain);
        $textRecords = dns_get_record($host, DNS_TXT);

        if ($textRecords === false) {
            return false;
        }

dns_get_record return FALSE if error dns/internet/format domain.
if no record - dns_get_record return EMPTY ARRAY - not FALSE!
try: var_export(dns_get_record('ssss1ss sssssssss.zzzzzzzzzzz', DNS_TXT)); - return FALSE (space at domain)
try: var_export(dns_get_record('ssss1sssssssssss.zzzzzzzzzzz', DNS_TXT)); - return array()

if false - this error get aka TEMPFAIL
if empty array - NO REC or NO DOMAIN aka PERMFAIL
must be as:

 if ($textRecords === false || empty($textRecords)) {
            return $textRecords;
        }

line:165

                if ($dnsKeys === false) {
                    $output[$signatureIndex][] = [
                        'status' => 'TEMPFAIL',
                        'reason' => 'Public key not found in DNS',
                    ];
                    continue;
                }

must as ~

                 if ($dnsKeys === false) {
                    $output[$signatureIndex][] = [
                        'status' => 'TEMPFAIL',
                        'reason' => 'Error DNS or NETWORK',
                    ];
                    continue;
                }
                if (empty($dnsKeys)) {
                    $output[$signatureIndex][] = [
                        'status' => 'PERMFAIL',
                        'reason' => 'Public key not found in DNS',
                    ];
                    continue;
                }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions