ISPconfig stable-3.1(latest) DKIM generation possible problem

Discussion in 'Developers' Forum' started by zsirmo, Aug 16, 2018.

  1. zsirmo

    zsirmo New Member

    Hello,

    I have a problem with ispconfig3 dkim generator.
    Situation:
    - select email domain edit
    - click "DomainKeys Id...." button, open/show hidden div area
    - click "Generate DKIM Private-key"
    - after click, DKIM-selector field value changed to empty, privkey generated, but DNS-record wrong (e.g.: "._domainkey.example.hu. 3600 TXT v=DKIM1; t=s; p="

    Please help investigate the problem. This problem multiple on servers.
     
  2. zsirmo

    zsirmo New Member

    I checked the git and code.
    Old ispconfig3-stable-3.1-caeab8c0d6f9dfee562bd557a2d5953a615e1bda is good.

    I checked ajax_get_json.php and line 59 "else" missing. Copy from old version else, and paste, and working this function.
     
    ahrasis, till and Taleman like this.
  3. till

    till Super Moderator Staff Member ISPConfig Developer

    Thank you for the report and fix.

    Are you sure about line 59? Line 59 is the line "if ($dkim_public != '' && $maildomain != '') {", If I compare the current code with the old version, then I would say that "} else {" is missing in line 77. But I have not tested it yet.
     
  4. zsirmo

    zsirmo New Member

    Code:
    diff -Nru ajax_get_json_orig.php ajax_get_json.php
    --- ajax_get_json_orig.php      2018-08-06 17:01:24.000000000 +0200
    +++ ajax_get_json.php   2018-08-16 15:25:51.189154493 +0200
    @@ -78,7 +78,12 @@
                    exec('echo '.escapeshellarg($dkim_private).'|openssl rsa -pubout -outform PEM 2> /dev/null',$pubkey,$result);
                    foreach($pubkey as $values) $dkim_public=$dkim_public.$values."\n";
                    $selector = $dkim_selector;
    -       }
    +       } else {
    +                unset($dkim_public);
    +                exec('echo '.escapeshellarg($dkim_private).'|openssl rsa -pubout -outform PEM 2> /dev/null',$pubkey,$result);
    +                foreach($pubkey as $values) $dkim_public=$dkim_public.$values."\n";
    +                $selector = $dkim_selector;
    +        }
    
            $dns_record=str_replace(array('-----BEGIN PUBLIC KEY-----','-----END PUBLIC KEY-----',"\r","\n"),'',$dkim_public);
            $dns_record = str_replace(array("\r\n", "\n", "\r"),'',$dns_record);
    
     
    till likes this.
  5. florian030

    florian030 Well-Known Member HowtoForge Supporter

    i think, that you don't need else:
    Code:
    if ($dkim_public != '' && $maildomain != '') {
    (...)
    } else {
        $selector = 'invalid domain or selector';
    }
    // add
    }
    (...)
    $selector = $dkim_selector;
    // remove
    // }
    
     

Share This Page